Skip to content

Commit

Permalink
Add lastOpenedAt and JoinedAt for communities (#18439)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil authored Jan 28, 2024
1 parent 205b74c commit 3020206
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/legacy/status_im/data_store/communities.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
:tokenPermissions :token-permissions
:communityTokensMetadata :tokens-metadata
:introMessage :intro-message
:muteTill :muted-till})
:muteTill :muted-till
:lastOpenedAt :last-opened-at
:joinedAt :joined-at})
(update :admin-settings
set/rename-keys
{:pinMessageAllMembersEnabled :pin-message-all-members-enabled?})
Expand Down
19 changes: 17 additions & 2 deletions src/status_im/contexts/communities/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,16 @@
(rf/merge
cofx
{:fx [[:dispatch [:communities/fetch-community deserialized-key]]
[:dispatch [:navigate-to :community-overview deserialized-key]]]}
[:dispatch [:navigate-to :community-overview deserialized-key]]
[:dispatch [:communities/update-last-opened-at deserialized-key]]]}
(navigation/pop-to-root :shell-stack)))))

(rf/reg-event-fx :communities/navigate-to-community-chat
(fn [{:keys [db]} [chat-id pop-to-root?]]
(let [{:keys [community-id]} (get-in db [:chats chat-id])]
{:fx [(when community-id
[:dispatch [:communities/fetch-community community-id]])
[:dispatch [:communities/fetch-community community-id]]
[:dispatch [:communities/update-last-opened-at community-id]])
(if pop-to-root?
[:dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]]
[:dispatch [:chat/navigate-to-chat chat-id]])]})))
Expand Down Expand Up @@ -424,3 +426,16 @@
(fn [{:keys [db]} [community-id]]
(when (get-in db [:communities community-id])
{:db (update-in db [:communities community-id] dissoc :fetching-revealed-accounts)})))

(rf/reg-event-fx :communities/update-last-opened-at
(fn [_ [community-id]]
{:json-rpc/call [{:method "wakuext_communityUpdateLastOpenedAt"
:params [community-id]
:on-success #(rf/dispatch [:communities/update-last-opened-at-success community-id
%])
:on-error #(log/error (str "failed to update last opened at for community "
%))}]}))

(rf/reg-event-fx :communities/update-last-opened-at-success
(fn [{:keys [db]} [community-id last-opened-at]]
{:db (assoc-in db [:communities community-id :last-opened-at] last-opened-at)}))
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.172.6",
"commit-sha1": "6e30fbb211b0e0bb1e7966cce4e215c4080aac5c",
"src-sha256": "1k3hg2m25qvgvqxmy8im3xhjwvdyvaq49yks92642h9rw494nb94"
"version": "v0.172.8",
"commit-sha1": "436d22985661322ffda4eb44c1a160e6804f3823",
"src-sha256": "1y3l469k2085qaml7dmaky1rlanl4phq2p6yyk97074yw839jzj1"
}

0 comments on commit 3020206

Please sign in to comment.