fix pinned message for community channels (#14885)
This commit is contained in:
parent
55caf0230e
commit
d16baca64f
|
@ -217,7 +217,8 @@
|
||||||
: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]}]
|
||||||
|
(let [pinned-message (get-in db [:pin-messages chat-id message-id])]
|
||||||
(rf/merge
|
(rf/merge
|
||||||
cofx
|
cofx
|
||||||
{:json-rpc/call [{:method "wakuext_editMessage"
|
{:json-rpc/call [{:method "wakuext_editMessage"
|
||||||
|
@ -229,8 +230,13 @@
|
||||||
constants/content-type-text)}]
|
constants/content-type-text)}]
|
||||||
:js-response true
|
:js-response true
|
||||||
:on-error #(log/error "failed to edit message " %)
|
:on-error #(log/error "failed to edit message " %)
|
||||||
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])}]}
|
:on-success (fn [result]
|
||||||
(cancel-message-edit)))
|
(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,13 +10,12 @@
|
||||||
(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
|
||||||
(assoc message :content message-content-sub)
|
message
|
||||||
{:group-chat group-chat
|
{:group-chat group-chat
|
||||||
:public? public?
|
:public? public?
|
||||||
:community? community?
|
:community? community?
|
||||||
|
@ -26,12 +25,12 @@
|
||||||
: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