Skip to content

Commit

Permalink
refactored mute chat drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-mut committed Jun 23, 2023
1 parent 8d10107 commit d9f1ab8
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/quo2/components/community/community_list_view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
:resize-mode :center
:size 20
:color (colors/theme-colors
colors/neutral-40
colors/neutral-50)}]
colors/neutral-50
colors/neutral-40)}]
(pos? unread-mentions-count)
[counter/counter {:type :default} unread-mentions-count]

Expand Down
14 changes: 8 additions & 6 deletions src/quo2/components/list_items/channel.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
[{:keys [locked? mentions-count unread-messages?
muted? is-active-channel? emoji channel-color]
:or {channel-color colors/primary-50}
:as props}
community-muted?]
:as props}]
(let [standard-props (apply dissoc props custom-props)
name-text (:name props)]
[rn/touchable-opacity standard-props
Expand Down Expand Up @@ -54,20 +53,23 @@
[rn/view
{:style {:height 20
:justify-content :center}}
(js/console.log (str "muted status " muted?))
(when (and (not locked?)
(or muted? community-muted?))
muted?)
[quo2.icons/icon :i/muted
{:size 20
:color colors/neutral-40}])
:color (colors/theme-colors
colors/neutral-50
colors/neutral-40)}])
(when (and (not locked?)
(or (not muted?) (not community-muted?))
(not 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?)
(or (not muted?) (not community-muted?))
(not muted?)
(not (pos? (int mentions-count)))
unread-messages?)
[unread-grey-dot :unviewed-messages-public])]]]))
14 changes: 9 additions & 5 deletions src/status_im2/common/home/actions/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[status-im2.contexts.contacts.drawers.nickname-drawer.view :as nickname-drawer]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
[status-im2.common.mute-chat-drawer.view :as mute-chat-drawer]
[status-im2.common.mute-drawer.view :as mute-chat-drawer]
[utils.datetime :as datetime]))

(defn- entry
Expand Down Expand Up @@ -53,11 +53,15 @@
:accessibility-label :edit-nickname}])}]))

(defn mute-chat-action
[chat-id chat-type]
[chat-id chat-type muted?]
(hide-sheet-and-dispatch [:show-bottom-sheet
{:content (fn []
[mute-chat-drawer/mute-chat-drawer chat-id
:mute-chat-for-duration chat-type])}]))
[mute-chat-drawer/mute-drawer
{:id chat-id
:community? false
:chat-type chat-type
:muted? muted?
:accessibility-label :mute-chat-title}])}]))

(defn unmute-chat-action
[chat-id]
Expand Down Expand Up @@ -136,7 +140,7 @@
(datetime/format-mute-till muted-till)))
:on-press (if muted?
#(unmute-chat-action chat-id)
#(mute-chat-action chat-id chat-type))
#(mute-chat-action chat-id chat-type muted?))
:danger? false
:accessibility-label :mute-chat
:chevron? true})))
Expand Down
12 changes: 2 additions & 10 deletions src/status_im2/common/mute_drawer/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@
constants/one-to-one-chat-type}
chat-type))

(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 [id community? muted? muted-type]}]
(rf/dispatch [:hide-bottom-sheet])
(if community?
(mute-community id muted? muted-type)
(mute-chat id)))
(rf/dispatch [:community/set-muted id muted? muted-type])
(rf/dispatch [:chat.ui/mute id muted? muted-type])))

(defn mute-drawer
[{:keys [id accessibility-label muted? chat-type community?]}]
Expand Down
14 changes: 9 additions & 5 deletions src/status_im2/contexts/communities/actions/chat/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[status-im2.common.not-implemented :as not-implemented]
[utils.datetime :as datetime]
[utils.i18n :as i18n]
[status-im2.common.mute-chat-drawer.view :as mute-chat-drawer]
[status-im2.common.mute-drawer.view :as mute-chat-drawer]
[utils.re-frame :as rf]))

(defn hide-sheet-and-dispatch
Expand All @@ -12,11 +12,15 @@
(rf/dispatch event))

(defn- mute-channel-action
[chat-id chat-type]
[chat-id chat-type muted?]
(hide-sheet-and-dispatch [:show-bottom-sheet
{:content (fn []
[mute-chat-drawer/mute-chat-drawer chat-id
:mute-chat-for-duration chat-type])}]))
[mute-chat-drawer/mute-drawer
{:id chat-id
:community? false
:chat-type chat-type
:muted? muted?
:accessibility-label :mute-channel-title}])}]))

(defn- unmute-channel-action
[chat-id]
Expand Down Expand Up @@ -54,7 +58,7 @@
(str (i18n/label :t/muted-until) " " (datetime/format-mute-till muted-till)))
:on-press (if muted?
#(unmute-channel-action id)
#(mute-channel-action id chat-type))
#(mute-channel-action id chat-type muted?))
:label (i18n/label (if muted
:t/unmute-channel
:t/mute-channel))}))
Expand Down
15 changes: 4 additions & 11 deletions src/status_im2/contexts/communities/overview/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

(defn channel-list-component
[{:keys [on-category-layout community-id on-first-channel-height-changed]}
channels-list community-muted?]
channels-list]
[rn/view
{:on-layout #(on-first-channel-height-changed
(+ (if platform/ios? 0 38)
Expand Down Expand Up @@ -98,8 +98,7 @@
(rf/dispatch [:show-bottom-sheet
{:content (fn [] [actions/chat-actions chat false])
:selected-item (fn []
[quo/channel-list-item chat])}])))
community-muted?]])])])])
[quo/channel-list-item chat])}])))]])])])])

(defn request-to-join-text
[is-open?]
Expand Down Expand Up @@ -269,12 +268,11 @@
description])

(defn community-content
[{:keys [name description joined tags id muted]
[{:keys [name description joined tags id]
:as community}
pending?
{:keys [on-category-layout on-first-channel-height-changed]}]
(let [chats-by-category (rf/sub [:communities/categorized-channels id])
community-muted? muted]
(let [chats-by-category (rf/sub [:communities/categorized-channels id])]
[:<>
[rn/view {:style style/community-content-container}
[status-tag pending? joined]
Expand All @@ -289,12 +287,7 @@
{:on-category-layout on-category-layout
:community-id id
:on-first-channel-height-changed on-first-channel-height-changed}
<<<<<<< HEAD
(add-handlers-to-categorized-chats id chats-by-category)]]))
=======
(add-on-press-handler-to-categorized-chats id chats-by-category)
community-muted?]]))
>>>>>>> 62b37a39e (mute and unmute community)

(defn sticky-category-header
[_]
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": "919123e1d6905825c6768b48a8ae781d084ecd61",
"src-sha256": "0z0jsgi7nfsc3ayv4vk47f6v3wc0vcfszj1fq09cl90yidv0wlwg"
"commit-sha1": "3af0b17c4cf52a6d257456a1b8f4a714fb013994",
"src-sha256": "1zhcrcvala5wjlzifq3npxw87fkkzhrdbq1q5dq9b7mzikq5lqyc"
}

0 comments on commit d9f1ab8

Please sign in to comment.