Skip to content

Commit

Permalink
mute and unmute community
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-mut committed Jun 6, 2023
1 parent ba4e2f7 commit 496c50a
Show file tree
Hide file tree
Showing 16 changed files with 329 additions and 113 deletions.
25 changes: 25 additions & 0 deletions 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
mute and unmute community

https://github.com/status-im/status-go/compare/aded83fc...76b04d59

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Thu May 25 11:47:19 2023 +0300
#
# On branch mute-community
# Changes to be committed:
# modified: ios/Podfile.lock
# modified: src/quo2/components/community/community_list_view.cljs
# modified: src/quo2/components/list_items/channel.cljs
# modified: src/status_im/communities/core.cljs
# modified: src/status_im/data_store/chats.cljs
# modified: src/status_im2/common/bottom_sheet/styles.cljs
# deleted: src/status_im2/common/mute_chat_drawer/view.cljs
# renamed: src/status_im2/common/mute_chat_drawer/style.cljs -> src/status_im2/common/mute_drawer/style.cljs
# new file: src/status_im2/common/mute_drawer/view.cljs
# modified: src/status_im2/contexts/communities/actions/community_options/view.cljs
# modified: src/status_im2/contexts/communities/overview/view.cljs
# modified: status-go-version.json
# modified: translations/en.json
#
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,11 @@ SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
CryptoSwift: c4f2debceb38bf44c80659afe009f71e23e4a082
DoubleConversion: cde416483dac037923206447da6e1454df403714
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
FBLazyVector: d2db9d00883282819d03bbd401b2ad4360d47580
FBReactNativeSpec: 94da4d84ba3b1acf459103320882daa481a2b62d
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 997518ea2aa2d8cd5df9797b641b758d52ecf2bc
glog: 3ac2326f7fee4840a3066c90eb135ecd20496ded
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
Keycard: ac6df4d91525c3c82635ac24d4ddd9a80aca5fc8
libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
Expand Down Expand Up @@ -763,4 +763,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: c29de3b14e3275299c51aa95520622f09d084bcb

COCOAPODS: 1.12.1
COCOAPODS: 1.12.0
10 changes: 5 additions & 5 deletions src/quo2/components/community/community_list_view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{:keys [name
locked?
status
muted?
muted
unread-messages?
unread-mentions-count
community-icon
Expand All @@ -59,7 +59,7 @@
:accessibility-label :community-name-text
:number-of-lines 1
:ellipsize-mode :tail
:style {:color (when muted?
:style {:color (when muted
(colors/theme-colors
colors/neutral-40
colors/neutral-60))}}
Expand All @@ -71,14 +71,14 @@
{:locked? locked?
:tokens tokens}]
[notification-view
{:muted? muted?
{:muted? muted
:unread-mentions-count unread-mentions-count
:unread-messages? unread-messages?}])]]]])

(defn communities-membership-list-item
[props
{:keys [name
muted?
muted
unviewed-messages-count
unviewed-mentions-count
status
Expand Down Expand Up @@ -116,6 +116,6 @@
{:locked? locked?
:tokens tokens}]
[notification-view
{:muted? muted?
{:muted? muted
:unread-mentions-count unviewed-mentions-count
:unread-messages? (pos? unviewed-messages-count)}])]]])
9 changes: 5 additions & 4 deletions src/quo2/components/list_items/channel.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
(defn list-item
[{:keys [name locked? mentions-count unread-messages?
muted? is-active-channel? emoji channel-color on-press]
:or {channel-color colors/primary-50}}]
:or {channel-color colors/primary-50}}
community-muted?]
[rn/touchable-opacity {:on-press on-press}
[rn/view
{:style (merge {:height 48
Expand Down Expand Up @@ -47,19 +48,19 @@
{:style {:height 20
:justify-content :center}}
(when (and (not locked?)
muted?)
(or muted? community-muted?))
[quo2.icons/icon :i/muted
{:size 20
:no-color true}])
(when (and (not locked?)
(not muted?)
(or (not muted?) (not community-muted?))
(pos? (int mentions-count)))
[rn/view
{:style {:margin-right 2
:margin-top 2}}
[quo2.counter/counter {:override-bg-color channel-color} mentions-count]])
(when (and (not locked?)
(not muted?)
(or (not muted?) (not community-muted?))
(not (pos? (int mentions-count)))
unread-messages?)
[unread-grey-dot :unviewed-messages-public])]]])
28 changes: 27 additions & 1 deletion src/status_im/communities/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
:isMember :is-member?
:adminSettings :admin-settings
:tokenPermissions :token-permissions
:communityTokensMetadata :tokens-metadata})
:communityTokensMetadata :tokens-metadata
:muteTill :muted-till})
(update :admin-settings
set/rename-keys
{:pinMessageAllMembersEnabled :pin-message-all-members-enabled?})
Expand Down Expand Up @@ -932,3 +933,28 @@
{:error %
:event
:communities/check-and-delete-pending-request-to-join-community})}]})

(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?))})

(rf/defn mute-community-successfully
{:events [:community/mute-community-successful]}
[{:keys [db]} community-id muted-till]
(log/debug "muted community successfully" community-id muted-till)
(js/console.log (str "muted community successfully " 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]
(let [params [community-id muted? muted-type]]
{:db (assoc-in db [:communities community-id :muted] muted?)
:json-rpc/call [{:method "wakuext_muteCommunityChats"
:params params
:on-error #(rf/dispatch [:community/mute-community-failed community-id
muted? %])
:on-success #(rf/dispatch [:community/mute-community-successful community-id
%])}]}))
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 @@ -81,7 +81,7 @@
:alias (.-alias chat)
:muted (.-muted chat)
:joined (.-joined chat)
:muted-till (.-mutetill chat)
:muted-till (.-muteTill chat)
:chat-id (.-id chat)
:community-id (.-communityId chat)
:synced-from (.-syncedFrom chat)
Expand Down
15 changes: 8 additions & 7 deletions src/status_im2/common/bottom_sheet/styles.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@

(defn selected-item
[override-theme]
{:position :absolute
:bottom 10
:left 0
:right 0
:border-radius 12
:margin-horizontal 8
:background-color (colors/theme-colors colors/white colors/neutral-90 override-theme)})
{:position :absolute
:bottom 10
:left 0
:right 0
:border-radius 12
:margin-horizontal 8
:padding-horizontal 12
:background-color (colors/theme-colors colors/white colors/neutral-90 override-theme)})
65 changes: 0 additions & 65 deletions src/status_im2/common/mute_chat_drawer/view.cljs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns status-im2.common.mute-chat-drawer.style
(ns status-im2.common.mute-drawer.style
(:require [quo2.foundations.colors :as colors]))

(defn header-text
Expand Down
95 changes: 95 additions & 0 deletions src/status_im2/common/mute_drawer/view.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
(ns status-im2.common.mute-drawer.view
(:require [utils.i18n :as i18n]
[quo2.core :as quo]
[react-native.core :as rn]
[status-im2.constants :as constants]
[utils.re-frame :as rf]
[status-im2.common.mute-drawer.style :as style]))

(defn mute-chat
[id]
(rf/dispatch [:chat.ui/mute id]))

(defn mute-community
[id muted? muted-type]
(rf/dispatch [:community/set-muted id muted? muted-type]))

(defn hide-sheet-and-dispatch
[{:keys [chat-id community-id muted? type muted-type]}]
(rf/dispatch [:hide-bottom-sheet])
(if (= type :community)
(mute-community community-id muted? muted-type)
(mute-chat chat-id)))

(defn mute-drawer
[{:keys [chat-id community-id accessibility-label type muted?]}]
[rn/view {:accessibility-label accessibility-label}
[quo/text
{:weight :medium
:size :paragraph-2
:style (style/header-text)} (i18n/label (if community-id :t/mute-community :t/mute-channel))]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-15-mins)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:muted? muted?
:muted-type constants/mute-for-15-mins-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-1-hour)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:muted? muted?
:muted-type constants/mute-for-1-hour-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-8-hours)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:muted? muted?
:muted-type constants/mute-for-8-hours-type}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-for-1-week)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:muted? muted?
:muted-type constants/mute-for-1-week}))}]
[quo/menu-item
{:type :transparent
:title (i18n/label :t/mute-till-unmute)
:icon-bg-color :transparent
:container-padding-vertical 12
:title-column-style {:margin-left 2}
:on-press (fn []
(hide-sheet-and-dispatch
{:chat-id chat-id
:type type
:community-id community-id
:muted? muted?
:muted-type constants/mute-till-unmuted}))}]])
27 changes: 27 additions & 0 deletions src/status_im2/constants.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,30 @@
(def ^:const auth-method-biometric "biometric")
(def ^:const auth-method-biometric-prepare "biometric-prepare")
(def ^:const auth-method-none "none")

(def ^:const int->weekday
"Maps the corresponding string representation of a weekday
By it's numeric index as in cljs-time"
{1 "mon"
2 "tue"
3 "wed"
4 "thu"
5 "fri"
6 "sat"
7 "sun"})

(def ^:const months
"Maps the corresponding string representation of a weekday
By it's numeric index as in cljs-time"
{1 "jan"
2 "feb"
3 "mar"
4 "apr"
5 "may"
6 "jun"
7 "jul"
8 "aug"
9 "sep"
10 "oct"
11 "nov"
12 "dec"})
Loading

0 comments on commit 496c50a

Please sign in to comment.