fix pinned message for community channels (#14885)

This commit is contained in:
Parvesh Monu 2023-01-30 19:42:58 +05:30 committed by GitHub
parent 55caf0230e
commit d16baca64f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 38 deletions

View File

@ -217,20 +217,26 @@
:text (i18n/label :t/update-to-see-sticker {"locale" "en"})})))
(rf/defn send-edited-message
[{:keys [db] :as cofx} text {:keys [message-id quoted-message]}]
(rf/merge
cofx
{:json-rpc/call [{:method "wakuext_editMessage"
:params [{:id message-id
:text text
:content-type (if (message-content/emoji-only-content?
{:text text :response-to quoted-message})
constants/content-type-emoji
constants/content-type-text)}]
:js-response true
:on-error #(log/error "failed to edit message " %)
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])}]}
(cancel-message-edit)))
[{: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
cofx
{:json-rpc/call [{:method "wakuext_editMessage"
:params [{:id message-id
:text text
:content-type (if (message-content/emoji-only-content?
{:text text :response-to quoted-message})
constants/content-type-emoji
constants/content-type-text)}]
:js-response true
:on-error #(log/error "failed to edit message " %)
: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
"Sends message from current chat input"

View File

@ -64,5 +64,5 @@
:accessory :text
:accessory-text (count pinned-messages)
: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])}]])]))))

View File

@ -100,7 +100,7 @@
:accessory :text
:accessory-text 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}])
(defn nickname-settings

View File

@ -215,7 +215,8 @@
:accessory :text
:accessory-text (count pinned-messages)
: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?
[quo/list-item
{:theme :negative

View File

@ -324,12 +324,6 @@
(rf/dispatch [:bottom-sheet/hide])
(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
{:events [:chat.ui/navigate-to-horizontal-images]}
[cofx messages index]

View File

@ -10,28 +10,27 @@
(def list-key-fn #(or (:message-id %) (:value %)))
(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]}]
;; 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
(assoc message :content message-content-sub)
{:group-chat group-chat
:public? public?
:community? community?
:current-public-key current-public-key
:show-input? show-input?
:message-pin-enabled true
:in-pinned-view? true
:pinned true
:timestamp-str (datetime/timestamp->time whisper-timestamp)
:edit-enabled edit-enabled}]))
[message/message-with-reactions
message
{:group-chat group-chat
:public? public?
:community? community?
:current-public-key current-public-key
:show-input? show-input?
:message-pin-enabled true
:in-pinned-view? true
:pinned true
:timestamp-str (datetime/timestamp->time whisper-timestamp)
:edit-enabled edit-enabled}])
(defn pinned-messages-list
[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)])]
[rn/view {:accessibility-label :pinned-messages-list}
;; TODO (flexsurfer) this should be a component in quo2