Skip to content

Commit

Permalink
cleanup mutetill on unmute
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil committed Mar 12, 2023
1 parent f3c9d7a commit 439fd3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/status_im/data_store/chats.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
:identicon (.-identicon chat)
:muted (.-muted chat)
:joined (.-joined chat)

:muted-till (.-mutetill chat)
:chat-id (.-id chat)
:community-id (.-communityId chat)
:synced-from (.-syncedFrom chat)
Expand Down
23 changes: 13 additions & 10 deletions src/status_im2/contexts/chat/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@
(defn map-chats
[{:keys [db] :as cofx}]
(fn [val]
(assoc
(merge
(or (get (:chats db) (:chat-id val))
(create-new-chat (:chat-id val) cofx))
val)
:invitation-admin
(:invitation-admin val))))
(let [chat (or (get (:chats db) (:chat-id val))
(create-new-chat (:chat-id val) cofx))]
(assoc
(merge
(cond-> chat
(comp not :muted) (dissoc chat :muted-till))
val)
:invitation-admin
(:invitation-admin val)))))

(rf/defn leave-removed-chat
[{{:keys [view-id current-chat-id chats]} :db
Expand Down Expand Up @@ -291,8 +293,9 @@

(rf/defn mute-chat-toggled-successfully
{:events [:chat/mute-successfully]}
[_ chat-id]
(log/debug "muted chat successfully" chat-id))
[{:keys [db]} chat-id muted-till]
(log/debug "muted chat successfully" chat-id " for" muted-till)
{:db (assoc-in db [:chats chat-id :muted-till] muted-till)})

(rf/defn mute-chat
{:events [:chat.ui/mute]}
Expand All @@ -303,7 +306,7 @@
:json-rpc/call [{:method method
:params params
:on-error #(rf/dispatch [:chat/mute-failed chat-id muted? %])
:on-success #(rf/dispatch [:chat/mute-successfully chat-id])}]}))
:on-success #(rf/dispatch [:chat/mute-successfully chat-id %])}]}))

(rf/defn show-clear-history-confirmation
{:events [:chat.ui/show-clear-history-confirmation]}
Expand Down

0 comments on commit 439fd3a

Please sign in to comment.