add mark all read for communities

Signed-off-by: Michele Balistreri <michele@bitgamma.com>
This commit is contained in:
Michele Balistreri 2021-09-15 14:44:10 +03:00
parent 716e72fb5f
commit 5b72e749e3
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
5 changed files with 42 additions and 14 deletions

View File

@ -45,12 +45,21 @@
(when current-chat-id
{:db (assoc-in db [:pagination-info current-chat-id :loading-messages?] false)}))
(defn mark-chat-all-read
[db chat-id]
(update-in db [:chats chat-id] assoc
:unviewed-messages-count 0
:unviewed-mentions-count 0))
(fx/defn handle-mark-all-read-successful
{:events [::mark-all-read-successful]}
[{:keys [db]} chat-id]
{:db (update-in db [:chats chat-id] assoc
:unviewed-messages-count 0
:unviewed-mentions-count 0)})
{:db (mark-chat-all-read db chat-id)})
(fx/defn handle-mark-all-read-in-community-successful
{:events [::mark-all-read-in-community-successful]}
[{:keys [db]} chat-ids]
{:db (reduce mark-chat-all-read db chat-ids)})
(fx/defn handle-mark-all-read
{:events [:chat.ui/mark-all-read-pressed :chat/mark-all-as-read]}
@ -60,6 +69,14 @@
:params [chat-id]
:on-success #(re-frame/dispatch [::mark-all-read-successful chat-id])}]})
(fx/defn handle-mark-mark-all-read-in-community
{:events [:chat.ui/mark-all-read-in-community-pressed]}
[_ community-id]
{:clear-message-notifications community-id
::json-rpc/call [{:method (json-rpc/call-ext-method "markAllReadInCommunity")
:params [community-id]
:on-success #(re-frame/dispatch [::mark-all-read-in-community-successful %])}]})
(fx/defn messages-loaded
"Loads more messages for current chat"
{:events [::messages-loaded]}

View File

@ -80,6 +80,7 @@
"wakuext_deleteMessage" {}
"wakuext_markMessagesSeen" {}
"wakuext_markAllRead" {}
"wakuext_markAllReadInCommunity" {}
"wakuext_confirmMessagesProcessedByID" {}
"wakuext_updateMessageOutgoingStatus" {}
"wakuext_chatMessages" {}

View File

@ -117,6 +117,12 @@
true
name
(or color (rand-nth colors/chat-colors))])}]
[quo/list-item
{:theme :accent
:title (i18n/label :t/mark-all-read)
:accessibility-label :mark-all-read-button
:icon :main-icons/check
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-in-community-pressed id])}]
(when can-manage-users?
[:<>
[quo/list-item

View File

@ -12,6 +12,7 @@
[status-im.ui.components.toolbar :as toolbar]
[status-im.ui.components.badge :as badge]
[status-im.ui.components.react :as react]
[status-im.ui.screens.communities.community :as community]
[status-im.ui.screens.communities.icon :as communities.icon]
[quo.design-system.colors :as quo.colors]))
@ -35,13 +36,16 @@
:accessibility-label :unviewed-messages-public}])))
(defn community-home-list-item [{:keys [id name last?] :as community}]
[react/touchable-opacity {:style (merge {:height 64}
(when last?
{:border-bottom-color (quo.colors/get-color :ui-01)
:border-bottom-width 1}))
:on-press (fn []
(>evt [:dismiss-keyboard])
(>evt [:navigate-to :community {:community-id id}]))}
[react/touchable-opacity {:style (merge {:height 64}
(when last?
{:border-bottom-color (quo.colors/get-color :ui-01)
:border-bottom-width 1}))
:on-press (fn []
(>evt [:dismiss-keyboard])
(>evt [:navigate-to :community {:community-id id}]))
:on-long-press #(>evt [:bottom-sheet/show-sheet
{:content (fn []
[community/community-actions community])}])}
[:<>
[react/view {:top 12 :left 16 :position :absolute}
[communities.icon/community-icon community]]

View File

@ -1,9 +1,9 @@
{
"_comment": "THIS SHOULD NOT BE EDITTED BY HAND.",
"_comment": "THIS SHOULD NOT BE EDITED BY HAND.",
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.86.7",
"commit-sha1": "93497f464410864ecf386e7494a544969ba9bd9e",
"src-sha256": "01kvn8bkijrlxar3ky2cyiwxvzig8h23wl3cazx4zamqgpnpijhq"
"version": "v0.87.0",
"commit-sha1": "fb218761d9d1620916ae7e8b19b9b4a03f92c767",
"src-sha256": "073qgjfn2cn1li6g4r38xizkifsl4xd1sm51784jmy7kq6gqs1gr"
}