diff --git a/src/status_im/chat/models/reactions.cljs b/src/status_im/chat/models/reactions.cljs index dab685e28d..219314f6e3 100644 --- a/src/status_im/chat/models/reactions.cljs +++ b/src/status_im/chat/models/reactions.cljs @@ -104,7 +104,6 @@ :emoji-id emoji-id :from from}) - (defn- format-response [response] (->> (transforms/js->clj response) @@ -113,24 +112,22 @@ (rf/defn save-emoji-reaction-details {:events [:chat/save-emoji-reaction-details]} - [{:keys [db]} message-reactions long-pressed-emoji] - {:db (assoc db - :chat/reactions-authors - {:reaction-authors-list message-reactions - :selected-reaction long-pressed-emoji})}) + [{:keys [db]} reaction-authors] + {:db (assoc db :chat/reactions-authors reaction-authors)}) (rf/defn clear-emoji-reaction-details {:events [:chat/clear-emoji-reaction-author-details]} - [{:keys [db]} message-reactions] - {:db (update db dissoc :chat/reactions-authors)}) + [{:keys [db]}] + {:db (dissoc db :chat/reactions-authors)}) (rf/defn emoji-reactions-by-message-id {:events [:chat.ui/emoji-reactions-by-message-id]} - [{:keys [db]} {:keys [message-id long-pressed-emoji]}] - {:json-rpc/call [{:method "wakuext_emojiReactionsByChatIDMessageID" + [{:keys [db]} {:keys [message-id on-success]}] + {:db (dissoc db :chat/reactions-authors) + :json-rpc/call [{:method "wakuext_emojiReactionsByChatIDMessageID" :params [(:current-chat-id db) message-id] :js-response true :on-error #(log/error "failed to fetch emoji reaction by message-id: " {:message-id message-id :error %}) - :on-success #(rf/dispatch [:chat/save-emoji-reaction-details - (format-response %) long-pressed-emoji])}]}) + :on-success #(when on-success + (on-success (format-response %)))}]}) diff --git a/src/status_im2/contexts/chat/messages/content/reactions/view.cljs b/src/status_im2/contexts/chat/messages/content/reactions/view.cljs index 288fc301fd..495fee9186 100644 --- a/src/status_im2/contexts/chat/messages/content/reactions/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/reactions/view.cljs @@ -17,25 +17,23 @@ :emoji-id emoji-id}]))) (defn- on-long-press - [message-id emoji-id] + [message-id emoji-id user-message-content reactions] (rf/dispatch [:chat.ui/emoji-reactions-by-message-id - {:message-id message-id - :long-pressed-emoji emoji-id}])) - -(defn show-authors-sheet - [user-message-content reactions] - (rf/dispatch [:dismiss-keyboard]) - (rf/dispatch - [:show-bottom-sheet - {:on-close (fn [] - (rf/dispatch - [:chat/clear-emoji-reaction-author-details])) - :content (fn [] - [drawers/reaction-authors - (map :emoji-id reactions)]) - :selected-item (fn [] - user-message-content) - :padding-bottom-override 0}])) + {:message-id message-id + :on-success (fn [response] + (rf/dispatch [:chat/save-emoji-reaction-details + {:reaction-authors-list response + :selected-reaction emoji-id}]) + (rf/dispatch [:dismiss-keyboard]) + (rf/dispatch [:show-bottom-sheet + {:on-close (fn [] + (rf/dispatch + [:chat/clear-emoji-reaction-author-details])) + :content (fn [] + [drawers/reaction-authors reactions]) + :selected-item (fn [] + user-message-content) + :padding-bottom-override 0}]))}])) (defn message-reactions-row [{:keys [message-id chat-id]} user-message-content] @@ -55,11 +53,10 @@ :neutral? own :clicks quantity :on-press #(on-press own message-id emoji-id emoji-reaction-id) - :on-long-press (fn [] - (on-long-press message-id - emoji-id) - (show-authors-sheet user-message-content - reactions)) + :on-long-press #(on-long-press message-id + emoji-id + user-message-content + (map :emoji-id reactions)) :accessibility-label (str "emoji-reaction-" emoji-id)}]]) [quo/add-reaction {:on-press (fn []