Skip to content

Commit

Permalink
update community chats mute status
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-mut committed Jun 27, 2023
1 parent 3f05bde commit a96bc32
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 142 deletions.
5 changes: 2 additions & 3 deletions src/quo2/components/list_items/channel.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@
[rn/view
{:style {:height 20
:justify-content :center}}
(js/console.log (str "muted status " muted?))
(when (and (not locked?)
muted?)
[quo2.icons/icon :i/muted
{:size 20
:color (colors/theme-colors
colors/neutral-50
:color (colors/theme-colors
colors/neutral-50
colors/neutral-40)}])
(when (and (not locked?)
(not muted?)
Expand Down
31 changes: 25 additions & 6 deletions src/status_im/communities/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,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 @@ -934,18 +934,37 @@
:event
:communities/check-and-delete-pending-request-to-join-community})}]})

(rf/defn mute-community-chats
{:events [:community/mute-community-chats]}
[{:keys [db]} chat-id muted? muted-till]
(log/debug "muted community chat successfully" chat-id muted?)
{:db (update-in db [:chats chat-id] merge {:muted muted? :muted-till muted-till})})

(rf/defn mute-and-unmute-community-chats
{:events [:community/update-community-chats-mute-status]}
[{:keys [db]} community-id muted? mute-till]
(let [channels (get-in db [:communities community-id :chats])
chats (mapv vector (keys channels) (vals channels))]
(doseq [x chats]
(doseq [{:keys [id]} x]
(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?))})
{: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-till]
[{:keys [db]} community-id muted? muted-till]
(log/debug "muted community successfully" community-id muted-till)
(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/defn set-community-muted
{:events [:community/set-muted]}
[{:keys [db]} community-id muted? muted-type]
Expand All @@ -956,5 +975,5 @@
:params params
:on-error #(rf/dispatch [:community/mute-community-failed community-id
muted? %])
:on-success #(rf/dispatch [:community/mute-community-successful community-id
%])}]}))
:on-success #(rf/dispatch [:community/mute-community-successful
community-id muted? %])}]}))
76 changes: 0 additions & 76 deletions src/status_im2/common/mute_chat_drawer/view.cljs

This file was deleted.

50 changes: 25 additions & 25 deletions src/status_im2/common/mute_drawer/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-for-15-mins-type}))}]
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-for-15-mins-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-1-hour)
Expand All @@ -54,11 +54,11 @@
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-for-1-hour-type}))}]
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-for-1-hour-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-8-hours)
Expand All @@ -67,11 +67,11 @@
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-for-8-hours-type}))}]
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-for-8-hours-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-1-week)
Expand All @@ -80,11 +80,11 @@
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-for-1-week}))}]
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-for-1-week}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-till-unmute)
Expand All @@ -93,8 +93,8 @@
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-till-unmuted}))}]])
{:id id
:chat-type chat-type
:muted? muted?
:community? community?
:muted-type constants/mute-till-unmuted}))}]])
2 changes: 1 addition & 1 deletion src/status_im2/contexts/communities/actions/chat/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[chat-id chat-type muted?]
(hide-sheet-and-dispatch [:show-bottom-sheet
{:content (fn []
[mute-drawer/mute-drawer
[mute-drawer/mute-drawer
{:id chat-id
:community? false
:muted? (not muted?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,15 @@
[quo2.core :as quo]
[status-im2.contexts.communities.actions.see-rules.view :as see-rules]
[status-im2.contexts.communities.actions.leave.view :as leave-menu]
[status-im2.contexts.communities.actions.token-gating.view :as token-gating]
[status-im2.common.mute-drawer.view :as mute-options]
[status-im2.constants :as constants]))
[status-im2.constants :as constants]
[status-im2.contexts.communities.actions.token-gating.view :as token-gating]))

(defn hide-sheet-and-dispatch
[event]
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch event))

(defn muted-type
[duration]
(cond
(= duration 1)
(str (i18n/label :muted-for) duration (i18n/label :minutes))

(= duration 2)
(str (i18n/label :muted-for) duration (i18n/label :hour))

(= duration 3)
(str (i18n/label :muted-for) duration (i18n/label :hours))

(= duration 4)
(str (i18n/label :muted-for) duration (i18n/label :days))

:else
""))

(defn view-members
[id]
{:icon :i/members
Expand Down Expand Up @@ -178,15 +160,15 @@

(defn get-context-drawers
[{:keys [id]}]
(let [{:keys [token-gated? admin joined
muted muted-till banList]} (rf/sub [:communities/community id])
(let [{:keys [token-permissions admin joined
muted banList muted-till]} (rf/sub [:communities/community id])
request-id (rf/sub [:communities/my-pending-request-to-join id])]
(cond
admin (owner-options id token-gated? muted muted-till)
joined (joined-options id token-gated? muted muted-till)
request-id (join-request-sent-options id token-gated? request-id)
banList (banned-options id token-gated?)
:else (not-joined-options id token-gated?))))
admin (owner-options id token-permissions muted muted-till)
joined (joined-options id token-permissions muted muted-till)
request-id (join-request-sent-options id token-permissions request-id)
banList (banned-options id token-permissions)
:else (not-joined-options id token-permissions))))

(defn community-options-bottom-sheet
[id]
Expand Down
3 changes: 1 addition & 2 deletions src/utils/datetime.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
[cljs-time.format :as t.format]
[clojure.string :as string]
[utils.i18n :as i18n]
[utils.i18n-goog :as i18n-goog]
[status-im2.constants :as constants]))
[utils.i18n-goog :as i18n-goog]))

(defn now [] (t/now))

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": "3af0b17c4cf52a6d257456a1b8f4a714fb013994",
"src-sha256": "1zhcrcvala5wjlzifq3npxw87fkkzhrdbq1q5dq9b7mzikq5lqyc"
"commit-sha1": "276ec9262f364676caac50af5b31dd465344d649",
"src-sha256": "10df2vbm11v8694g6x1cfd33yqdi4iqfc33939zxghfqkgzh0kgf"
}

0 comments on commit a96bc32

Please sign in to comment.