Skip to content

Commit

Permalink
added mute and unmute community toast
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-mut committed Jul 6, 2023
1 parent f91210c commit e494c57
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 24 deletions.
12 changes: 10 additions & 2 deletions src/quo2/components/community/community_list_view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[quo2.components.community.style :as style]
[quo2.components.counter.counter :as counter]
[quo2.components.icon :as icons]
[quo2.theme :as theme]
[quo2.components.markdown.text :as text]
[quo2.foundations.colors :as colors]
[quo2.components.community.icon :as community-icon]
Expand Down Expand Up @@ -77,6 +78,7 @@

(defn communities-membership-list-item
[props
bottom-sheet?
{:keys [name
muted
unviewed-messages-count
Expand Down Expand Up @@ -105,11 +107,17 @@
:number-of-lines 1
:ellipsize-mode :tail
:weight :semi-bold
:size :paragraph-1}
:size :paragraph-1
:style (when muted
{:color (if (theme/dark?)
colors/neutral-60
colors/neutral-40)})}
name]]

[rn/view
{:justify-content :center}
{:justify-content :center
:margin-right (when bottom-sheet?
16)}
(if (= status :gated)
[community-view/permission-tag-container
{:locked? locked?
Expand Down
31 changes: 15 additions & 16 deletions src/status_im/communities/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@
{:events [::requests-to-join-fetched]}
[{:keys [db]} community-id requests]
{:db (assoc-in db
[:communities/requests-to-join community-id]
(<-requests-to-join-community-rpc requests :id))})
[:communities/requests-to-join community-id]
(<-requests-to-join-community-rpc requests :id))})

(rf/defn fetch-requests-to-join
{:events [::fetch-requests-to-join]}
Expand Down Expand Up @@ -949,35 +949,34 @@
chats (mapv vector (keys channels) (vals channels))]
(doseq [x chats]
(doseq [{:keys [id]} x]
(js/console.log (str "chat muted " x muted?))
(let [chat-id (str community-id id)]
(rf/dispatch [:community/mute-community-chats chat-id muted? mute-till]))))))

(rf/defn mute-chat-failed
{:events [:community/mute-community-failed]}
[{:keys [db]} community-id muted? error]
(log/error "mute community failed" community-id error)
{:db (update-in db [:communities community-id :muted] (not muted?))
:dispatch [:toasts/upsert
{:icon :correct
:icon-color (quo2.colors/theme-colors quo2.colors/success-60
quo2.colors/success-50)
:text "Unmuted successfully"}]}
{:db (update-in db [:communities community-id :muted] (not muted?))}
(rf/dispatch [:community/update-community-chats-mute-status community-id muted? error]))

(rf/defn mute-community-successfully
{:events [:community/mute-community-successful]}
[{:keys [db]} community-id muted? muted-till]
(log/debug "muted community successfully" community-id muted-till)
(let [time-string (fn [duration-kw unmute-time]
(i18n/label duration-kw {:duration unmute-time}))]
#(rf/dispatch [:community/update-community-chats-mute-status community-id muted? muted-till])
{:db (assoc-in db [:communities community-id :muted-till] muted-till)
(rf/dispatch [:community/update-community-chats-mute-status community-id muted? muted-till])
(let [time-string (fn [mute-title mute-duration]
(i18n/label mute-title {:duration mute-duration}))]
{:db (assoc-in db [:communities community-id :muted-till] muted-till)
:dispatch [:toasts/upsert
{:icon :correct
:icon-color (quo2.colors/theme-colors quo2.colors/success-60
quo2.colors/success-50)
:text (when (some? muted-till)
(time-string :t/muted-until (datetime/format-mute-till muted-till)))}]}))
:icon-color (quo2.colors/theme-colors
quo2.colors/success-60
quo2.colors/success-50)
:text (if muted?
(when (some? muted-till)
(time-string :t/muted-until (datetime/format-mute-till muted-till)))
(i18n/label :t/community-unmuted))}]}))


(rf/defn set-community-muted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

(defn mute-community
[id muted? muted-till]
(let [time-string (fn [duration-kw unmute-time]
(i18n/label duration-kw {:duration unmute-time}))]
(let [time-string (fn [mute-title mute-duration]
(i18n/label mute-title {:duration mute-duration}))]
{:icon (if muted? :i/muted :i/activity-center)
:accessibility-label (if muted? :unmute-community :mute-community)
:label (i18n/label (if muted? :t/unmute-community :t/mute-community))
Expand Down
3 changes: 2 additions & 1 deletion src/status_im2/contexts/communities/home/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
{:content (fn []
[options/community-options-bottom-sheet id])
:selected-item (fn []
[quo/communities-membership-list-item {} item])}])}
[quo/communities-membership-list-item {} true item])}])}
false
item]))

(def tabs-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
{:padding-vertical 60
:justify-content :center}
[community-list-view/communities-membership-list-item {}
false
(cond-> (merge @state data/community)
(= :muted (:notifications @state))
(assoc :muted? true)
Expand Down
4 changes: 2 additions & 2 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"owner": "status-im",
"repo": "status-go",
"version": "ft/mute-community",
"commit-sha1": "dc50ac217c7be374e57eec803b59895035a10ff2",
"src-sha256": "0r5kmbz3aqpl0kkqpnw7nlrqh3a7ynzwfa7p4dpcnaccsnlaq4mp"
"commit-sha1": "c06f7a6c381488ce52cf212193970a079750c6fd",
"src-sha256": "1gbbq16phjkqxbijcflcvb2vx5z1s6i3bbsycpi1dbhxi3cq8y14"
}
3 changes: 2 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2242,5 +2242,6 @@
"until": "until",
"chat-unmuted-successfully": "Chat unmuted successfully! ",
"channel-unmuted-successfully": "Channel unmuted successfully! ",
"photo-saved": "Photo saved to your device"
"photo-saved": "Photo saved to your device",
"community-unmuted": "Community unmuted"
}

0 comments on commit e494c57

Please sign in to comment.