fix pinned message for community channels (#14885)
This commit is contained in:
parent
55caf0230e
commit
d16baca64f
|
@ -217,20 +217,26 @@
|
||||||
:text (i18n/label :t/update-to-see-sticker {"locale" "en"})})))
|
:text (i18n/label :t/update-to-see-sticker {"locale" "en"})})))
|
||||||
|
|
||||||
(rf/defn send-edited-message
|
(rf/defn send-edited-message
|
||||||
[{:keys [db] :as cofx} text {:keys [message-id quoted-message]}]
|
[{:keys [db] :as cofx} text {:keys [message-id quoted-message chat-id]}]
|
||||||
(rf/merge
|
(let [pinned-message (get-in db [:pin-messages chat-id message-id])]
|
||||||
cofx
|
(rf/merge
|
||||||
{:json-rpc/call [{:method "wakuext_editMessage"
|
cofx
|
||||||
:params [{:id message-id
|
{:json-rpc/call [{:method "wakuext_editMessage"
|
||||||
:text text
|
:params [{:id message-id
|
||||||
:content-type (if (message-content/emoji-only-content?
|
:text text
|
||||||
{:text text :response-to quoted-message})
|
:content-type (if (message-content/emoji-only-content?
|
||||||
constants/content-type-emoji
|
{:text text :response-to quoted-message})
|
||||||
constants/content-type-text)}]
|
constants/content-type-emoji
|
||||||
:js-response true
|
constants/content-type-text)}]
|
||||||
:on-error #(log/error "failed to edit message " %)
|
:js-response true
|
||||||
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])}]}
|
:on-error #(log/error "failed to edit message " %)
|
||||||
(cancel-message-edit)))
|
:on-success (fn [result]
|
||||||
|
(re-frame/dispatch [:sanitize-messages-and-process-response
|
||||||
|
result])
|
||||||
|
(when pinned-message
|
||||||
|
(re-frame/dispatch [:pin-message/load-pin-messages
|
||||||
|
chat-id])))}]}
|
||||||
|
(cancel-message-edit))))
|
||||||
|
|
||||||
(rf/defn send-current-message
|
(rf/defn send-current-message
|
||||||
"Sends message from current chat input"
|
"Sends message from current chat input"
|
||||||
|
|
|
@ -64,5 +64,5 @@
|
||||||
:accessory :text
|
:accessory :text
|
||||||
:accessory-text (count pinned-messages)
|
:accessory-text (count pinned-messages)
|
||||||
:chevron true
|
:chevron true
|
||||||
:on-press #(re-frame/dispatch [:chat.ui/navigate-to-pinned-messages
|
:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet :pinned-messages-list
|
||||||
chat-id])}]])]))))
|
chat-id])}]])]))))
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
:accessory :text
|
:accessory :text
|
||||||
:accessory-text pin-count
|
:accessory-text pin-count
|
||||||
:disabled (zero? pin-count)
|
:disabled (zero? pin-count)
|
||||||
:on-press #(re-frame/dispatch [:chat.ui/navigate-to-pinned-messages public-key])
|
:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet :pinned-messages-list public-key])
|
||||||
:chevron true}])
|
:chevron true}])
|
||||||
|
|
||||||
(defn nickname-settings
|
(defn nickname-settings
|
||||||
|
|
|
@ -215,7 +215,8 @@
|
||||||
:accessory :text
|
:accessory :text
|
||||||
:accessory-text (count pinned-messages)
|
:accessory-text (count pinned-messages)
|
||||||
:chevron true
|
:chevron true
|
||||||
:on-press #(re-frame/dispatch [:chat.ui/navigate-to-pinned-messages chat-id])}]
|
:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet :pinned-messages-list
|
||||||
|
chat-id])}]
|
||||||
(when member?
|
(when member?
|
||||||
[quo/list-item
|
[quo/list-item
|
||||||
{:theme :negative
|
{:theme :negative
|
||||||
|
|
|
@ -324,12 +324,6 @@
|
||||||
(rf/dispatch [:bottom-sheet/hide])
|
(rf/dispatch [:bottom-sheet/hide])
|
||||||
(rf/dispatch [:chat.ui/remove-chat chat-id]))}})
|
(rf/dispatch [:chat.ui/remove-chat chat-id]))}})
|
||||||
|
|
||||||
(rf/defn navigate-to-user-pinned-messages
|
|
||||||
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
|
|
||||||
{:events [:chat.ui/navigate-to-pinned-messages]}
|
|
||||||
[cofx chat-id]
|
|
||||||
(navigation/navigate-to cofx :chat-pinned-messages {:chat-id chat-id}))
|
|
||||||
|
|
||||||
(rf/defn navigate-to-horizontal-images
|
(rf/defn navigate-to-horizontal-images
|
||||||
{:events [:chat.ui/navigate-to-horizontal-images]}
|
{:events [:chat.ui/navigate-to-horizontal-images]}
|
||||||
[cofx messages index]
|
[cofx messages index]
|
||||||
|
|
|
@ -10,28 +10,27 @@
|
||||||
(def list-key-fn #(or (:message-id %) (:value %)))
|
(def list-key-fn #(or (:message-id %) (:value %)))
|
||||||
|
|
||||||
(defn message-render-fn
|
(defn message-render-fn
|
||||||
[{:keys [whisper-timestamp message-id chat-id] :as message}
|
[{:keys [whisper-timestamp] :as message}
|
||||||
_
|
_
|
||||||
{:keys [group-chat public? community? current-public-key show-input? edit-enabled]}]
|
{:keys [group-chat public? community? current-public-key show-input? edit-enabled]}]
|
||||||
;; TODO (flexsurfer) probably we don't want reactions here
|
;; TODO (flexsurfer) probably we don't want reactions here
|
||||||
(let [message-content-sub (get-in (rf/sub [:chats/chat-messages chat-id]) [message-id :content])]
|
[message/message-with-reactions
|
||||||
[message/message-with-reactions
|
message
|
||||||
(assoc message :content message-content-sub)
|
{:group-chat group-chat
|
||||||
{:group-chat group-chat
|
:public? public?
|
||||||
:public? public?
|
:community? community?
|
||||||
:community? community?
|
:current-public-key current-public-key
|
||||||
:current-public-key current-public-key
|
:show-input? show-input?
|
||||||
:show-input? show-input?
|
:message-pin-enabled true
|
||||||
:message-pin-enabled true
|
:in-pinned-view? true
|
||||||
:in-pinned-view? true
|
:pinned true
|
||||||
:pinned true
|
:timestamp-str (datetime/timestamp->time whisper-timestamp)
|
||||||
:timestamp-str (datetime/timestamp->time whisper-timestamp)
|
:edit-enabled edit-enabled}])
|
||||||
:edit-enabled edit-enabled}]))
|
|
||||||
|
|
||||||
(defn pinned-messages-list
|
(defn pinned-messages-list
|
||||||
[chat-id]
|
[chat-id]
|
||||||
(let [pinned-messages (vec (vals (rf/sub [:chats/pinned chat-id])))
|
(let [pinned-messages (vec (vals (rf/sub [:chats/pinned chat-id])))
|
||||||
current-chat (rf/sub [:chats/current-chat])
|
current-chat (rf/sub [:chat-by-id chat-id])
|
||||||
community (rf/sub [:communities/community (:community-id current-chat)])]
|
community (rf/sub [:communities/community (:community-id current-chat)])]
|
||||||
[rn/view {:accessibility-label :pinned-messages-list}
|
[rn/view {:accessibility-label :pinned-messages-list}
|
||||||
;; TODO (flexsurfer) this should be a component in quo2
|
;; TODO (flexsurfer) this should be a component in quo2
|
||||||
|
|
Loading…
Reference in New Issue