Skip to content

Commit

Permalink
feat: dapp connected notification
Browse files Browse the repository at this point in the history
  • Loading branch information
yqrashawn committed Jul 29, 2024
1 parent 1f5bb57 commit e714064
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 13 deletions.
18 changes: 11 additions & 7 deletions src/legacy/status_im/data_store/activities.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@
[item]
(-> item
rpc->type
(set/rename-keys {:lastMessage :last-message
:replyMessage :reply-message
:chatId :chat-id
:contactVerificationStatus :contact-verification-status
:communityId :community-id
:membershipStatus :membership-status
:albumMessages :album-messages})
(set/rename-keys {:lastMessage :last-message
:replyMessage :reply-message
:chatId :chat-id
:contactVerificationStatus :contact-verification-status
:communityId :community-id
:membershipStatus :membership-status
:albumMessages :album-messages
:walletProviderSessionTopic :wallet-provider-session-topic
:dappURL :dapp-url
:dappName :dapp-name
:dappIconURL :dapp-icon-url})
(update :last-message #(when % (messages/<-rpc %)))
(update :message #(when % (messages/<-rpc %)))
(update :reply-message #(when % (messages/<-rpc %)))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(ns status-im.contexts.shell.activity-center.notification.dapp-connection.view
(:require
[quo.core :as quo]
[quo.foundations.resources :as quo.resources]
[status-im.contexts.shell.activity-center.notification.common.view :as common]
[utils.datetime :as datetime]
[utils.i18n :as i18n]
utils.url))

(defn view
[{:keys [customization-color active-swipeable notification extra-fn]}]
(let [{:keys [timestamp read dapp-url dapp-icon-url]} notification]
[common/swipeable
{:left-button common/swipe-button-read-or-unread
:left-on-press common/swipe-on-press-toggle-read
:right-button common/swipe-button-delete
:right-on-press common/swipe-on-press-delete
:active-swipeable active-swipeable
:extra-fn extra-fn}
[quo/activity-log
{:title (i18n/label :t/connected-to-dapp)
:customization-color customization-color
:icon :i/dapps
:timestamp (datetime/timestamp->relative timestamp)
:unread? (not read)
:context [[quo/context-tag
{:type :dapp
:size 24
:dapp-logo dapp-icon-url
:dapp-name (utils.url/url-host dapp-url)}]
(i18n/label :t/via)
[quo/context-tag
{:type :dapp
:size 24
:dapp-logo (quo.resources/get-dapp :wallet-connect)
:dapp-name "WalletConnect"}]]}]]))
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
(def ^:const admin 8)
(def ^:const community-kicked 9)
(def ^:const contact-verification 10)
(def ^:const dapp-connected 23)
(def ^:const dapp-disconnected 24)

(def ^:const all-supported
#{one-to-one-chat
Expand All @@ -20,7 +22,8 @@
community-request
admin
community-kicked
contact-verification})
contact-verification
dapp-connected})

;; TODO: Replace with correct enum values once status-go implements them.
(def ^:const tx 66612)
Expand Down
4 changes: 4 additions & 0 deletions src/status_im/contexts/shell/activity_center/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
contact-requests]
[status-im.contexts.shell.activity-center.notification.contact-verification.view :as
contact-verification]
[status-im.contexts.shell.activity-center.notification.dapp-connection.view :as dapp-connection]
[status-im.contexts.shell.activity-center.notification.membership.view :as membership]
[status-im.contexts.shell.activity-center.notification.mentions.view :as mentions]
[status-im.contexts.shell.activity-center.notification.reply.view :as reply]
Expand Down Expand Up @@ -51,6 +52,9 @@
(= type types/admin)
[admin/view props]

(= type types/dapp-connected)
[dapp-connection/view props]

(some types/membership [type])
(condp = type
types/private-group-chat [membership/view props]
Expand Down
3 changes: 2 additions & 1 deletion src/status_im/contexts/wallet/wallet_connect/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@
:params [(js/JSON.stringify session-info)]
:on-success (fn []
(log/info "Wallet Connect session persisted")
(rf/dispatch [:wallet-connect/fetch-persisted-sessions]))
(rf/dispatch [:wallet-connect/fetch-persisted-sessions])
(rf/dispatch [:activity-center.notifications/fetch-unread-count]))
:on-error #(log/info "Wallet Connect session persistence failed" %)}]]]}))

(rf/reg-event-fx
Expand Down
1 change: 0 additions & 1 deletion src/status_im/subs/wallet/activities.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[clojure.string :as string]
[native-module.core :as native-module]
[quo.foundations.resources :as quo.resources]
[quo.foundations.resources]
[re-frame.core :as rf]
[status-im.contexts.wallet.common.activity-tab.constants :as constants]
[utils.datetime :as datetime]
Expand Down
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.182.39",
"commit-sha1": "9755b3de7ae64929066d2b8a26222d8d41ceda87",
"src-sha256": "02b2fshb7phhsr7mghg4s6qr1n1c8xawaz4pw04q8hpv5vfnjcxz"
"version": "feat/wallet-connect-session-notification",
"commit-sha1": "f79484433acd64c5cf4dda0e93b7bf7883108bcc",
"src-sha256": "0rrx7njm00wbng30m1hqslc95l36zw0f0mlwxxgn0dj1srf0drkk"
}
1 change: 1 addition & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@
"connected": "Connected",
"connected-dapps": "Connected dApps",
"connected-to": "Connected to",
"connected-to-dapp": "Connected to dApp",
"connecting": "Connecting...",
"connecting-requires-login": "Connecting to another network requires login",
"connection-request": "Connection Request",
Expand Down

0 comments on commit e714064

Please sign in to comment.