Skip to content

Commit 8af7011

Browse files
authored
[15128] Introduce muting for a specific duration (#15253)
1 parent f6d74df commit 8af7011

File tree

14 files changed

+147
-49
lines changed

14 files changed

+147
-49
lines changed

src/quo2/components/list_items/menu_item.cljs

+11-11
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@
3030
(when on-press
3131
{:on-press on-press}))
3232
[rn/view
33-
{:style {:flex-direction :row
34-
:flex-grow 0
35-
:flex-shrink 1
36-
:padding-horizontal 20
37-
:align-items :center}}
33+
{:style (cond-> {:flex-direction :row
34+
:flex-grow 0
35+
:flex-shrink 1
36+
:align-items :center}
37+
icon (assoc :padding-horizontal 20))}
3838
[rn/view
39-
{:style {:width 20
40-
:height 20
41-
:align-items :center
42-
:justify-content :center
43-
:margin-right 12}}
44-
[icons/icon icon {:color icon-color}]]
39+
{:style (cond-> {:width 20
40+
:height 20
41+
:align-items :center
42+
:justify-content :center}
43+
icon (assoc :margin-right 12))}
44+
(when icon [icons/icon icon {:color icon-color}])]
4545
[rn/view
4646
[text/text
4747
{:weight :medium

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_im/integration_test.cljs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
status-im2.navigation.core
1313
status-im2.subs.root ; so integration tests can run independently
1414
[taoensso.timbre :as log]
15-
[utils.security.core :as security]))
15+
[utils.security.core :as security]
16+
[status-im2.constants :as constants]))
1617

1718
(def password "testabc")
1819

@@ -295,7 +296,7 @@
295296
(rf/dispatch-sync [:chat/navigate-to-chat chat-id])
296297
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
297298
(is @(rf/subscribe [:chats/chat chat-id]))
298-
(rf/dispatch-sync [:chat.ui/mute chat-id true])
299+
(rf/dispatch-sync [:chat.ui/mute chat-id true constants/mute-till-unmuted])
299300
(rf-test/wait-for
300301
[:chat/mute-successfully]
301302
(is @(rf/subscribe [:chats/muted chat-id]))

src/status_im/ui/screens/profile/contact/views.cljs

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
[status-im.ui.components.toolbar :as toolbar]
1414
[status-im.ui.components.topbar :as topbar]
1515
[status-im.ui.screens.profile.components.sheets :as sheets]
16-
[utils.re-frame :as rf]))
16+
[utils.re-frame :as rf]
17+
[status-im2.constants :as constants]))
1718

1819
(defn actions
1920
[{:keys [public-key added? blocked? ens-name mutual?] :as contact} muted?]
@@ -43,7 +44,9 @@
4344
:selected muted?
4445
:disabled blocked?
4546
:action (when-not blocked?
46-
#(re-frame/dispatch [:chat.ui/mute public-key (not muted?)]))}]
47+
#(re-frame/dispatch [:chat.ui/mute public-key (not muted?)
48+
(when-not muted?
49+
constants/mute-till-unmuted)]))}]
4750
[{:label (i18n/label (if blocked? :t/unblock :t/block))
4851
:negative true
4952
:selected blocked?

src/status_im2/common/home/actions/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
(defn mute-chat-action
5353
[chat-id]
54-
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true]))
54+
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true constants/mute-till-unmuted]))
5555

5656
(defn unmute-chat-action
5757
[chat-id]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(ns status-im2.common.mute-chat-drawer.style
2+
(:require [quo2.foundations.colors :as colors]))
3+
4+
(defn header-text
5+
[]
6+
{:margin-left 20
7+
:margin-bottom 10
8+
:color (colors/theme-colors colors/neutral-50 colors/neutral-40)})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
(ns status-im2.common.mute-chat-drawer.view
2+
(:require [utils.i18n :as i18n]
3+
[quo2.core :as quo]
4+
[react-native.core :as rn]
5+
[status-im2.constants :as constants]
6+
[utils.re-frame :as rf]
7+
[status-im2.common.mute-chat-drawer.style :as style]))
8+
9+
(defn hide-sheet-and-dispatch
10+
[event]
11+
(rf/dispatch [:bottom-sheet/hide])
12+
(rf/dispatch event))
13+
14+
(defn mute-chat-drawer
15+
[chat-id accessibility-label]
16+
[rn/view {:accessibility-label accessibility-label}
17+
[quo/text
18+
{:weight :medium
19+
:size :paragraph-2
20+
:style (style/header-text)} (i18n/label :t/mute-channel)]
21+
[quo/menu-item
22+
{:type :transparent
23+
:title (i18n/label :t/mute-for-15-mins)
24+
:icon-bg-color :transparent
25+
:container-padding-vertical 12
26+
:title-column-style {:margin-left 2}
27+
:on-press (fn []
28+
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
29+
constants/mute-for-15-mins-type]))}]
30+
[quo/menu-item
31+
{:type :transparent
32+
:title (i18n/label :t/mute-for-1-hour)
33+
:icon-bg-color :transparent
34+
:container-padding-vertical 12
35+
:title-column-style {:margin-left 2}
36+
:on-press (fn []
37+
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
38+
constants/mute-for-1-hour-type]))}]
39+
[quo/menu-item
40+
{:type :transparent
41+
:title (i18n/label :t/mute-for-8-hours)
42+
:icon-bg-color :transparent
43+
:container-padding-vertical 12
44+
:title-column-style {:margin-left 2}
45+
:on-press (fn []
46+
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
47+
constants/mute-for-8-hours-type]))}]
48+
[quo/menu-item
49+
{:type :transparent
50+
:title (i18n/label :t/mute-for-1-week)
51+
:icon-bg-color :transparent
52+
:container-padding-vertical 12
53+
:title-column-style {:margin-left 2}
54+
:on-press (fn []
55+
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
56+
constants/mute-for-1-week]))}]
57+
[quo/menu-item
58+
{:type :transparent
59+
:title (i18n/label :t/mute-till-unmute)
60+
:icon-bg-color :transparent
61+
:container-padding-vertical 12
62+
:title-column-style {:margin-left 2}
63+
:on-press (fn []
64+
(hide-sheet-and-dispatch [:chat.ui/mute chat-id true
65+
constants/mute-till-unmuted]))}]])

src/status_im2/constants.cljs

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
(def ^:const activity-center-membership-status-accepted 2)
3737
(def ^:const activity-center-membership-status-declined 3)
3838

39+
(def ^:const mute-for-15-mins-type 1)
40+
(def ^:const mute-for-1-hour-type 2)
41+
(def ^:const mute-for-8-hours-type 3)
42+
(def ^:const mute-for-1-week 4)
43+
(def ^:const mute-till-unmuted 5)
44+
3945
(def ^:const activity-center-mark-all-as-read-undo-time-limit-ms 4000)
4046
(def ^:const activity-center-max-unread-count 99)
4147

src/status_im2/contexts/chat/events.cljs

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

7577
(rf/defn leave-removed-chat
7678
[{{:keys [view-id current-chat-id chats]} :db
@@ -292,18 +294,20 @@
292294

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

298301
(rf/defn mute-chat
299302
{:events [:chat.ui/mute]}
300-
[{:keys [db]} chat-id muted?]
301-
(let [method (if muted? "wakuext_muteChat" "wakuext_unmuteChat")]
303+
[{:keys [db]} chat-id muted? mute-type]
304+
(let [method (if muted? "wakuext_muteChatV2" "wakuext_unmuteChat")
305+
params (if muted? [{:chatId chat-id :mutedType mute-type}] [chat-id])]
302306
{:db (assoc-in db [:chats chat-id :muted] muted?)
303307
:json-rpc/call [{:method method
304-
:params [chat-id]
308+
:params params
305309
:on-error #(rf/dispatch [:chat/mute-failed chat-id muted? %])
306-
:on-success #(rf/dispatch [:chat/mute-successfully chat-id])}]}))
310+
:on-success #(rf/dispatch [:chat/mute-successfully chat-id %])}]}))
307311

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

src/status_im2/contexts/chat/group_details/view.cljs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
[status-im2.common.contact-list-item.view :as contact-list-item]
99
[status-im2.common.home.actions.view :as actions]
1010
[utils.re-frame :as rf]
11-
[reagent.core :as reagent]))
11+
[reagent.core :as reagent]
12+
[status-im2.constants :as constants]))
1213

1314
(defn back-button
1415
[]
@@ -191,7 +192,8 @@
191192
[rn/touchable-opacity
192193
{:style (style/action-container color)
193194
:accessibility-label :toggle-mute
194-
:on-press #(rf/dispatch [:chat.ui/mute chat-id (not muted)])}
195+
:on-press #(rf/dispatch [:chat.ui/mute chat-id (not muted)
196+
(when-not muted constants/mute-till-unmuted)])}
195197
[quo/icon (if muted :i/muted :i/activity-center)
196198
{:size 20 :color (colors/theme-colors colors/neutral-100 colors/white)}]
197199
[quo/text {:style {:margin-top 16} :size :paragraph-1 :weight :medium}

src/status_im2/contexts/chat/home/chat_list_item/view.cljs

+7-6
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118

119119
(defn chat-list-item
120120
[{:keys [chat-id group-chat color name unviewed-messages-count unviewed-mentions-count
121-
timestamp last-message]
121+
timestamp last-message muted]
122122
:as item}]
123123
(let [display-name (if group-chat
124124
name
@@ -143,8 +143,9 @@
143143
:style {:color (colors/theme-colors colors/neutral-50 colors/neutral-40)}}
144144
(get-in last-message [:content :text])]
145145
[render-subheader (get-in last-message [:content :parsed-text])])]
146-
(if (> unviewed-mentions-count 0)
147-
[quo/info-count {:style {:top 16}}
148-
unviewed-mentions-count]
149-
(when (> unviewed-messages-count 0)
150-
[rn/view {:style (style/count-container)}]))]))
146+
(when-not muted
147+
(if (> unviewed-mentions-count 0)
148+
[quo/info-count {:style {:top 16}}
149+
unviewed-mentions-count]
150+
(when (> unviewed-messages-count 0)
151+
[rn/view {:style (style/count-container)}])))]))

src/status_im2/subs/shell.cljs

+9-7
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,19 @@
156156
(fn [chats]
157157
(let [{:keys [chats-stack community-stack]}
158158
(reduce
159-
(fn [acc [_ {:keys [unviewed-messages-count unviewed-mentions-count chat-type]}]]
159+
(fn [acc [_ {:keys [unviewed-messages-count unviewed-mentions-count chat-type muted]}]]
160160
(case chat-type
161161
constants/community-chat-type
162-
(-> acc
163-
(update-in [:community-stack :unviewed-messages-count] + unviewed-messages-count)
164-
(update-in [:community-stack :unviewed-mentions-count] + unviewed-mentions-count))
162+
(when-not muted
163+
(-> acc
164+
(update-in [:community-stack :unviewed-messages-count] + unviewed-messages-count)
165+
(update-in [:community-stack :unviewed-mentions-count] + unviewed-mentions-count)))
165166

166167
(constants/private-group-chat-type constants/one-to-one-chat-type)
167-
(-> acc
168-
(update-in [:chats-stack :unviewed-messages-count] + unviewed-messages-count)
169-
(update-in [:chats-stack :unviewed-mentions-count] + unviewed-mentions-count))
168+
(when-not muted
169+
(-> acc
170+
(update-in [:chats-stack :unviewed-messages-count] + unviewed-messages-count)
171+
(update-in [:chats-stack :unviewed-mentions-count] + unviewed-mentions-count)))
170172

171173
acc))
172174
{:chats-stack {:unviewed-messages-count 0 :unviewed-mentions-count 0}

status-go-version.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
44
"owner": "status-im",
55
"repo": "status-go",
6-
"version": "v0.144.0",
7-
"commit-sha1": "ba1ba1ac0203948339be5877ea6e970efb7b8ee0",
8-
"src-sha256": "0r2gxivnx201zfnm69g2mk1izcjid4lf9s4ln721kwrnc1v288sf"
6+
"version": "v0.145.2",
7+
"commit-sha1": "719af90fcc077f301f50349c034938701883031e",
8+
"src-sha256": "1p93x7ph03aq95961j4098fy2p7a4ssymf4hf3kbl5ldmvdk403p"
99
}

translations/en.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -2064,5 +2064,11 @@
20642064
"enable-biometrics": "Enable biometrics",
20652065
"use-biometrics": "Use biometrics to fill in your password",
20662066
"name-must-have-at-least-characters": "Name must have at least {{min-chars}} characters",
2067-
"name-is-not-valid": "Name is not valid"
2067+
"name-is-not-valid": "Name is not valid",
2068+
"mute-for-15-mins": "For 15 min",
2069+
"mute-for-1-hour": "For 1 hour",
2070+
"mute-for-8-hours": "For 8 hours",
2071+
"mute-for-1-week": "For 7 days",
2072+
"mute-till-unmute": "Until you turn it back on",
2073+
"mute-channel": "Mute channel"
20682074
}

0 commit comments

Comments
 (0)