Skip to content

Commit 439fd3a

Browse files
committed
cleanup mutetill on unmute
1 parent f3c9d7a commit 439fd3a

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/status_im/data_store/chats.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
:identicon (.-identicon chat)
8888
:muted (.-muted chat)
8989
:joined (.-joined chat)
90-
90+
:muted-till (.-mutetill chat)
9191
:chat-id (.-id chat)
9292
:community-id (.-communityId chat)
9393
:synced-from (.-syncedFrom chat)

src/status_im2/contexts/chat/events.cljs

+13-10
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@
6363
(defn map-chats
6464
[{:keys [db] :as cofx}]
6565
(fn [val]
66-
(assoc
67-
(merge
68-
(or (get (:chats db) (:chat-id val))
69-
(create-new-chat (:chat-id val) cofx))
70-
val)
71-
:invitation-admin
72-
(:invitation-admin val))))
66+
(let [chat (or (get (:chats db) (:chat-id val))
67+
(create-new-chat (:chat-id val) cofx))]
68+
(assoc
69+
(merge
70+
(cond-> chat
71+
(comp not :muted) (dissoc chat :muted-till))
72+
val)
73+
:invitation-admin
74+
(:invitation-admin val)))))
7375

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

292294
(rf/defn mute-chat-toggled-successfully
293295
{:events [:chat/mute-successfully]}
294-
[_ chat-id]
295-
(log/debug "muted chat successfully" chat-id))
296+
[{:keys [db]} chat-id muted-till]
297+
(log/debug "muted chat successfully" chat-id " for" muted-till)
298+
{:db (assoc-in db [:chats chat-id :muted-till] muted-till)})
296299

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

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

0 commit comments

Comments
 (0)