Partial handlers update (re-frame/reg-event-fx instead of rf/defn) (#19005)
* Handlers update (re-frame/reg-event-fx instead of rf/defn) * Fixes * Fixes * Fixes
This commit is contained in:
parent
614b03d701
commit
fa9645d6dd
|
@ -15,6 +15,7 @@
|
|||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.common.universal-links :as links]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.chat.events :as chat.events]
|
||||
|
@ -654,12 +655,11 @@
|
|||
stored-bookmarks)]
|
||||
{:db (assoc db :bookmarks/bookmarks bookmarks)}))
|
||||
|
||||
(rf/defn initialize-browser
|
||||
[_]
|
||||
{:json-rpc/call
|
||||
[{:method "wakuext_getBrowsers"
|
||||
:on-success #(re-frame/dispatch [::initialize-browsers %])}
|
||||
{:method "browsers_getBookmarks"
|
||||
:on-success #(re-frame/dispatch [::initialize-bookmarks %])}
|
||||
{:method "permissions_getDappPermissions"
|
||||
:on-success #(re-frame/dispatch [::initialize-dapp-permissions %])}]})
|
||||
(re-frame/reg-fx :browser/initialize-browser
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_getBrowsers"
|
||||
:on-success [::initialize-browsers]})
|
||||
(json-rpc/call {:method "browsers_getBookmarks"
|
||||
:on-success [::initialize-bookmarks]})
|
||||
(json-rpc/call {:method "permissions_getDappPermissions"
|
||||
:on-success [::initialize-dapp-permissions]})))
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
[legacy.status-im.bottom-sheet.events :as bottom-sheet]
|
||||
legacy.status-im.communities.e2e
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.contexts.shell.activity-center.events :as activity-center]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
@ -84,13 +83,12 @@
|
|||
(navigation/navigate-back)
|
||||
(handle-response response-js)))
|
||||
|
||||
(rf/defn member-banned
|
||||
{:events [::member-banned]}
|
||||
[cofx response-js]
|
||||
(rf/merge cofx
|
||||
(bottom-sheet/hide-bottom-sheet-old)
|
||||
(handle-response response-js)
|
||||
(activity-center/notifications-fetch-unread-count)))
|
||||
(re-frame/reg-event-fx ::member-banned
|
||||
(fn [{:keys [db]} [response-js]]
|
||||
{:db (assoc db :bottom-sheet/show? false)
|
||||
:fx [[:dismiss-bottom-sheet-overlay-old]
|
||||
[:sanitize-messages-and-process-response response-js]
|
||||
[:activity-center.notifications/fetch-unread-count]]}))
|
||||
|
||||
(rf/defn member-ban
|
||||
{:events [::member-ban]}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
[re-frame.core :as re-frame]
|
||||
[status-im.contexts.chat.contacts.events :as contacts-store]
|
||||
[status-im.contexts.chat.messenger.messages.list.events :as message-list]
|
||||
[status-im.contexts.shell.activity-center.events :as activity-center]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -52,9 +51,9 @@
|
|||
(assoc-in [:contacts/contacts public-key
|
||||
:added?]
|
||||
false))
|
||||
:dispatch [:shell/close-switcher-card public-key]
|
||||
:effects/push-notifications-clear-message-notifications [public-key]}
|
||||
(activity-center/notifications-fetch-unread-count)
|
||||
:fx [[:activity-center.notifications/fetch-unread-count]
|
||||
[:effects/push-notifications-clear-message-notifications [public-key]]
|
||||
[:dispatch [:shell/close-switcher-card public-key]]]}
|
||||
fxs)))
|
||||
|
||||
(rf/defn block-contact
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
[clojure.set :as set]
|
||||
[legacy.status-im.data-store.messages :as messages]
|
||||
[legacy.status-im.utils.deprecated-types :as types]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn rpc->type
|
||||
[{:keys [chat-type name] :as chat}]
|
||||
|
@ -117,10 +118,10 @@
|
|||
rpc->type
|
||||
unmarshal-members))
|
||||
|
||||
(rf/defn fetch-chats-preview
|
||||
[_ {:keys [on-success]}]
|
||||
{:json-rpc/call [{:method "wakuext_chatsPreview"
|
||||
(re-frame/reg-fx :fetch-chats-preview
|
||||
(fn [{:keys [on-success]}]
|
||||
(json-rpc/call {:method "wakuext_chatsPreview"
|
||||
:params []
|
||||
:js-response true
|
||||
:on-success #(on-success ^js %)
|
||||
:on-error #(log/error "failed to fetch chats" 0 -1 %)}]})
|
||||
:on-error #(log/error "failed to fetch chats" 0 -1 %)})))
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
(:require
|
||||
[clojure.set :as set]
|
||||
[clojure.walk :as walk]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -32,11 +34,11 @@
|
|||
:on-success #()
|
||||
:on-error #()}]})
|
||||
|
||||
(rf/defn fetch-switcher-cards-rpc
|
||||
[_]
|
||||
{:json-rpc/call [{:method "wakuext_switcherCards"
|
||||
(re-frame/reg-fx :switcher-cards/fetch
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_switcherCards"
|
||||
:params []
|
||||
:on-success #(rf/dispatch
|
||||
[:shell/switcher-cards-loaded
|
||||
(:switcherCards ^js %)])
|
||||
:on-error #(log/error "Failed to fetch switcher cards" %)}]})
|
||||
:on-error #(log/error "Failed to fetch switcher cards" %)})))
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
(:require
|
||||
[clojure.set :as set]
|
||||
[re-frame.core :as re-frame]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn <-rpc
|
||||
[visibility-status-update]
|
||||
|
@ -18,13 +18,13 @@
|
|||
{:current-user-status :current-user-visibility-status})
|
||||
(update :current-user-visibility-status <-rpc)))
|
||||
|
||||
(rf/defn fetch-visibility-status-updates-rpc
|
||||
[_]
|
||||
{:json-rpc/call [{:method "wakuext_statusUpdates"
|
||||
(re-frame/reg-fx :visibility-status-updates/fetch
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_statusUpdates"
|
||||
:params []
|
||||
:on-success #(re-frame/dispatch
|
||||
[:visibility-status-updates/visibility-status-updates-loaded
|
||||
(:statusUpdates ^js %)])
|
||||
:on-error #(log/error
|
||||
"failed to fetch visibility-status-updates"
|
||||
%)}]})
|
||||
%)})))
|
||||
|
|
|
@ -239,7 +239,7 @@
|
|||
|
||||
(rf/defn tx-history-end-reached
|
||||
[{:keys [db] :as cofx} address]
|
||||
(let [syncing-allowed? (utils.mobile-sync/syncing-allowed? cofx)]
|
||||
(let [syncing-allowed? (utils.mobile-sync/syncing-allowed? db)]
|
||||
{:db (assoc-in db
|
||||
[:wallet-legacy :fetching address :all-fetched?]
|
||||
(if syncing-allowed?
|
||||
|
@ -327,7 +327,7 @@
|
|||
{:chain-tokens (:wallet-legacy/all-tokens db)
|
||||
:addresses [address]
|
||||
:before-block min-known-block
|
||||
:fetch-more? (utils.mobile-sync/syncing-allowed? cofx)
|
||||
:fetch-more? (utils.mobile-sync/syncing-allowed? db)
|
||||
;; Transfers are requested before and including `min-known-block` because there is no
|
||||
;; guarantee that all transfers from that block are shown already. To make sure that we fetch
|
||||
;; the whole `default-transfers-limit` of transfers the number of transfers already received
|
||||
|
|
|
@ -8,11 +8,16 @@
|
|||
legacy.status-im.chat.models.loading
|
||||
legacy.status-im.contact.block
|
||||
legacy.status-im.currency.core
|
||||
legacy.status-im.data-store.chats
|
||||
legacy.status-im.data-store.switcher-cards
|
||||
legacy.status-im.data-store.visibility-status-updates
|
||||
legacy.status-im.fleet.core
|
||||
legacy.status-im.group-chats.core
|
||||
[legacy.status-im.keycard.core :as keycard]
|
||||
legacy.status-im.log-level.core
|
||||
legacy.status-im.mailserver.constants
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
legacy.status-im.mobile-sync-settings.core
|
||||
legacy.status-im.multiaccounts.login.core
|
||||
legacy.status-im.multiaccounts.logout.core
|
||||
[legacy.status-im.multiaccounts.model :as multiaccounts.model]
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
[legacy.status-im.data-store.invitations :as data-store.invitations]
|
||||
[oops.core :as oops]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.chat.events :as chat.events]
|
||||
[status-im.contexts.shell.activity-center.events :as activity-center]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
@ -19,15 +19,13 @@
|
|||
(when (get-in cofx [:db :chats chat-id])
|
||||
(chat.events/pop-to-root-and-navigate-to-chat cofx chat-id nil)))
|
||||
|
||||
(rf/defn handle-chat-removed
|
||||
{:events [:chat-removed]}
|
||||
[cofx response chat-id]
|
||||
(rf/merge cofx
|
||||
{:db (dissoc (:db cofx) :current-chat-id)
|
||||
:dispatch-n [[:shell/close-switcher-card chat-id]
|
||||
[:sanitize-messages-and-process-response response]
|
||||
[:pop-to-root :shell-stack]]}
|
||||
(activity-center/notifications-fetch-unread-count)))
|
||||
(re-frame/reg-event-fx :chat-removed
|
||||
(fn [{:keys [db]} [response chat-id]]
|
||||
{:db (dissoc db :current-chat-id)
|
||||
:fx [[:dispatch [:shell/close-switcher-card chat-id]]
|
||||
[:dispatch [:sanitize-messages-and-process-response response]]
|
||||
[:dispatch [:pop-to-root :shell-stack]]
|
||||
[:activity-center.notifications/fetch-unread-count]]}))
|
||||
|
||||
(rf/defn handle-chat-update
|
||||
{:events [:chat-updated]}
|
||||
|
@ -264,8 +262,7 @@
|
|||
{}
|
||||
invitations))})
|
||||
|
||||
(rf/defn get-group-chat-invitations
|
||||
[_]
|
||||
{:json-rpc/call
|
||||
[{:method "wakuext_getGroupChatInvitations"
|
||||
:on-success #(re-frame/dispatch [::initialize-invitations %])}]})
|
||||
(re-frame/reg-fx :group-chats/get-group-chat-invitations
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_getGroupChatInvitations"
|
||||
:on-success [::initialize-invitations]})))
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
[legacy.status-im.node.core :as node]
|
||||
[legacy.status-im.utils.mobile-sync :as mobile-network-utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]
|
||||
|
@ -61,7 +62,7 @@
|
|||
(dissoc :mailserver/current-request :mailserver/fetching-gaps-in-progress))})
|
||||
|
||||
(defn fetch-use-mailservers?
|
||||
[{:keys [db]}]
|
||||
[db]
|
||||
(get-in db [:profile/profile :use-mailservers?]))
|
||||
|
||||
(defonce showing-connection-error-popup? (atom false))
|
||||
|
@ -117,16 +118,24 @@
|
|||
[{:keys [db] :as cofx}]
|
||||
{:db (dissoc db :mailserver/current-request)})
|
||||
|
||||
(defn needs-to-fetch-historic-messages?
|
||||
[db]
|
||||
(and
|
||||
(:messenger/started? db)
|
||||
(mobile-network-utils/syncing-allowed? db)
|
||||
(fetch-use-mailservers? db)
|
||||
(not (:mailserver/current-request db))))
|
||||
|
||||
(rf/defn process-next-messages-request
|
||||
{:events [::request-messages]}
|
||||
[{:keys [db now] :as cofx}]
|
||||
(when (and
|
||||
(:messenger/started? db)
|
||||
(mobile-network-utils/syncing-allowed? cofx)
|
||||
(fetch-use-mailservers? cofx)
|
||||
(not (:mailserver/current-request db)))
|
||||
[{:keys [db]}]
|
||||
(when (needs-to-fetch-historic-messages? db)
|
||||
{:db (assoc db :mailserver/current-request true)
|
||||
:json-rpc/call [{:method "wakuext_requestAllHistoricMessagesWithRetries"
|
||||
:mailserver/request-all-historic-messages nil}))
|
||||
|
||||
(re-frame/reg-fx :mailserver/request-all-historic-messages
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_requestAllHistoricMessagesWithRetries"
|
||||
:params [false]
|
||||
:js-response true
|
||||
:on-success #(do
|
||||
|
@ -134,7 +143,7 @@
|
|||
(re-frame/dispatch [::request-success %]))
|
||||
:on-error #(do
|
||||
(log/error "failed retrieve historical messages" %)
|
||||
(re-frame/dispatch [::request-error]))}]}))
|
||||
(re-frame/dispatch [::request-error]))})))
|
||||
|
||||
(rf/defn handle-mailserver-changed
|
||||
[{:keys [db] :as cofx} ms]
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
[legacy.status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[legacy.status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[legacy.status-im.utils.mobile-sync :as utils]
|
||||
[status-im.contexts.chat.home.add-new-contact.events :as add-new-contact]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
@ -18,27 +18,24 @@
|
|||
(or (nil? remember-choice?)
|
||||
remember-choice?))}))
|
||||
|
||||
(rf/defn on-network-status-change
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [initialized? (get db :network-status/initialized?)
|
||||
(re-frame/reg-event-fx :mobile-network/on-network-status-change
|
||||
(fn [{:keys [db]}]
|
||||
(let [previously-initialized? (get db :network-status/initialized?)
|
||||
logged-in? (multiaccounts.model/logged-in? db)
|
||||
{:keys [remember-syncing-choice?]} (:profile/profile db)]
|
||||
(apply
|
||||
rf/merge
|
||||
cofx
|
||||
{:db (assoc db :network-status/initialized? true)}
|
||||
(cond
|
||||
;; NOTE(rasom): When we log into account on-network-status-change is
|
||||
;; dispatched, but that doesn't mean there was a status change, thus
|
||||
;; no reason to restart wallet.
|
||||
(and logged-in? initialized?)
|
||||
[(mailserver/process-next-messages-request)
|
||||
(bottom-sheet/hide-bottom-sheet-old)
|
||||
#(add-new-contact/set-new-identity-reconnected %)]
|
||||
|
||||
logged-in?
|
||||
[(mailserver/process-next-messages-request)
|
||||
(bottom-sheet/hide-bottom-sheet-old)]))))
|
||||
fetch-historic-messages? (mailserver/needs-to-fetch-historic-messages? db)]
|
||||
(if logged-in?
|
||||
{:db (cond-> (-> db
|
||||
(assoc :network-status/initialized? true)
|
||||
(assoc :bottom-sheet/show? false))
|
||||
fetch-historic-messages?
|
||||
(assoc :mailserver/current-request true))
|
||||
:fx [(when fetch-historic-messages?
|
||||
[:mailserver/request-all-historic-messages])
|
||||
[:dismiss-bottom-sheet-overlay-old]
|
||||
(when previously-initialized?
|
||||
(let [new-identity-input (get-in db [:contacts/new-identity :input])]
|
||||
[:dispatch [:contacts/set-new-identity {:input new-identity-input}]]))]}
|
||||
{:db (assoc db :network-status/initialized? true)}))))
|
||||
|
||||
(defn apply-settings
|
||||
([sync?] (apply-settings sync? :default))
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns legacy.status-im.network.net-info
|
||||
(:require
|
||||
["@react-native-community/netinfo" :default net-info]
|
||||
[legacy.status-im.mobile-sync-settings.core :as mobile-network]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[taoensso.timbre :as log]
|
||||
|
@ -13,11 +12,11 @@
|
|||
{:db (assoc db :network-status (if is-connected? :online :offline))}))
|
||||
|
||||
(rf/defn change-network-type
|
||||
[{:keys [db] :as cofx} old-network-type network-type expensive?]
|
||||
[{:keys [db] :as cofx} network-type expensive?]
|
||||
(rf/merge cofx
|
||||
{:db (assoc db :network/type network-type)
|
||||
:network/notify-status-go [network-type expensive?]}
|
||||
(mobile-network/on-network-status-change)))
|
||||
:network/notify-status-go [network-type expensive?]
|
||||
:dispatch [:mobile-network/on-network-status-change]}))
|
||||
|
||||
(rf/defn handle-network-info-change
|
||||
{:events [::network-info-changed]}
|
||||
|
@ -37,7 +36,7 @@
|
|||
(when-not status-changed?
|
||||
(change-network-status isConnected))
|
||||
(when-not type-changed?
|
||||
(change-network-type old-network-type type (:is-connection-expensive details))))))
|
||||
(change-network-type type (:is-connection-expensive details))))))
|
||||
|
||||
(defn add-net-info-listener
|
||||
[]
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
(:require
|
||||
[legacy.status-im.utils.utils :as utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.re-frame :as rf]))
|
||||
|
@ -22,6 +23,21 @@
|
|||
:params [(chain/chain-id db) id]
|
||||
:on-success #()}]}))
|
||||
|
||||
(re-frame/reg-fx :stickers/load-packs
|
||||
(fn [chain-id]
|
||||
(json-rpc/call {:method "stickers_market"
|
||||
:params [chain-id]
|
||||
:on-success [:stickers/stickers-market-success]})
|
||||
(json-rpc/call {:method "stickers_installed"
|
||||
:params []
|
||||
:on-success [:stickers/stickers-installed-success]})
|
||||
(json-rpc/call {:method "stickers_pending"
|
||||
:params []
|
||||
:on-success [:stickers/stickers-pending-success]})
|
||||
(json-rpc/call {:method "stickers_recent"
|
||||
:params []
|
||||
:on-success [:stickers/stickers-recent-success]})))
|
||||
|
||||
(rf/defn load-packs
|
||||
{:events [:stickers/load-packs]}
|
||||
[{:keys [db]}]
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
(re-frame/reg-sub
|
||||
:mailserver/use-status-nodes?
|
||||
(fn [db _]
|
||||
(boolean (mailserver/fetch-use-mailservers? {:db db}))))
|
||||
(boolean (mailserver/fetch-use-mailservers? db))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:mailserver.edit/validation-errors
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
{:active (= value id)
|
||||
:accessory :radio
|
||||
:title (get titles id)
|
||||
:on-press #(re-frame/dispatch [:profile.settings/update-value :default-sync-period id])}])
|
||||
:on-press #(re-frame/dispatch [:profile.settings/profile-update :default-sync-period id])}])
|
||||
|
||||
(views/defview default-sync-period-settings
|
||||
[]
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
:subtitle (i18n/label :t/webview-camera-permission-requests-subtitle)
|
||||
:subtitle-max-lines 2
|
||||
:on-press #(re-frame/dispatch
|
||||
[:profile.settings/update-value
|
||||
[:profile.settings/profile-update
|
||||
:webview-allow-permission-requests?
|
||||
((complement boolean) webview-allow-permission-requests?)])}])
|
||||
[separator]
|
||||
|
@ -169,8 +169,7 @@
|
|||
{:active (= value id)
|
||||
:accessory :radio
|
||||
:title (get titles id)
|
||||
:on-press #(re-frame/dispatch [:profile.settings/update-value :profile-pictures-visibility
|
||||
id])}])
|
||||
:on-press #(re-frame/dispatch [:profile.settings/profile-update :profile-pictures-visibility id])}])
|
||||
|
||||
(views/defview profile-pic
|
||||
[]
|
||||
|
|
|
@ -51,4 +51,4 @@
|
|||
:icon :main-icons/delete
|
||||
:theme :accent
|
||||
:title (i18n/label :t/profile-pic-remove)
|
||||
:on-press #(re-frame/dispatch [:profile.settings/delete-profile-picture nil])}])]))
|
||||
:on-press #(re-frame/dispatch [:profile.settings/delete-profile-picture])}])]))
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
[re-frame.core :as re-frame]
|
||||
[react-native.mail :as react-native-mail]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.common.log :as log]
|
||||
[status-im.config :as config]
|
||||
[utils.datetime :as datetime]
|
||||
|
@ -31,11 +32,10 @@
|
|||
[{:keys [db]} node-version]
|
||||
{:db (assoc db :web3-node-version node-version)})
|
||||
|
||||
(rf/defn initialize-web3-client-version
|
||||
{:events [:logging/initialize-web3-client-version]}
|
||||
[_]
|
||||
{:json-rpc/call [{:method "web3_clientVersion"
|
||||
:on-success #(re-frame/dispatch [:logging/store-web3-client-version %])}]})
|
||||
(re-frame/reg-fx :logging/initialize-web3-client-version
|
||||
(fn []
|
||||
(json-rpc/call {:method "web3_clientVersion"
|
||||
:on-success [:logging/store-web3-client-version]})))
|
||||
|
||||
(defn extract-url-components
|
||||
[address]
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
(= network-type "cellular"))
|
||||
|
||||
(defn syncing-allowed?
|
||||
[{:keys [db]}]
|
||||
[db]
|
||||
(let [network (:network/type db)
|
||||
{:keys [syncing-on-mobile-network?]} (:profile/profile db)]
|
||||
(or (= network "wifi")
|
||||
|
|
|
@ -4,9 +4,7 @@
|
|||
[clojure.string :as string]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.config :as config]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(def logs-queue (atom #queue []))
|
||||
|
@ -52,9 +50,3 @@
|
|||
:logs/set-level
|
||||
(fn [level]
|
||||
(setup level)))
|
||||
|
||||
(rf/defn set-log-level
|
||||
[{:keys [db]} log-level]
|
||||
(let [log-level (or log-level config/log-level)]
|
||||
{:db (assoc-in db [:profile/profile :log-level] log-level)
|
||||
:logs/set-level log-level}))
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview]
|
||||
[status-im.contexts.chat.messenger.messages.transport.events :as messages.transport]
|
||||
[status-im.contexts.communities.discover.events]
|
||||
[status-im.contexts.profile.login.events :as profile.login]
|
||||
[status-im.contexts.profile.push-notifications.local.events :as local-notifications]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]
|
||||
|
@ -37,7 +36,9 @@
|
|||
^js event-js (.-event data)
|
||||
type (.-type data)]
|
||||
(case type
|
||||
"node.login" (profile.login/login-node-signal cofx (transforms/js->clj event-js))
|
||||
"node.login" {:fx [[:dispatch
|
||||
[:profile.login/login-node-signal
|
||||
(transforms/js->clj event-js)]]]}
|
||||
"backup.performed" {:db (assoc-in db
|
||||
[:profile/profile :last-backup]
|
||||
(.-lastBackup event-js))}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
(ns status-im.contexts.chat.contacts.events
|
||||
(:require
|
||||
[oops.core :as oops]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]
|
||||
|
@ -64,18 +66,21 @@
|
|||
(when (> (count events) 1)
|
||||
{:dispatch-n events}))))
|
||||
|
||||
(rf/defn initialize-contacts
|
||||
[_]
|
||||
{:json-rpc/call [{:method "wakuext_contacts"
|
||||
(re-frame/reg-event-fx :contacts/contacts-loaded
|
||||
(fn [{:keys [db]} [loaded-contacts]]
|
||||
(let [contacts (->> loaded-contacts
|
||||
(map <-rpc-js)
|
||||
(mapv (fn [{:keys [public-key] :as contact}] [public-key contact]))
|
||||
(into {}))]
|
||||
{:db (assoc db :contacts/contacts contacts)})))
|
||||
|
||||
(re-frame/reg-fx :contacts/initialize-contacts
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_contacts"
|
||||
:params []
|
||||
:js-response true
|
||||
:on-success #(rf/dispatch [:contacts/contacts-loaded (map <-rpc-js %)])
|
||||
:on-error #(log/error "failed to fetch contacts" %)}]})
|
||||
|
||||
(rf/defn contacts-loaded
|
||||
{:events [:contacts/contacts-loaded]}
|
||||
[{:keys [db]} contacts]
|
||||
{:db (assoc db :contacts/contacts (into {} (map #(vector (:public-key %) %) contacts)))})
|
||||
:on-success [:contacts/contacts-loaded]
|
||||
:on-error #(log/error "failed to fetch contacts" %)})))
|
||||
|
||||
(defn send-contact-request
|
||||
[{:keys [db]} [id message]]
|
||||
|
|
|
@ -186,9 +186,3 @@
|
|||
{:db (dissoc db :contacts/new-identity)})
|
||||
|
||||
(re-frame/reg-event-fx :contacts/clear-new-identity clear-new-identity)
|
||||
|
||||
(defn set-new-identity-reconnected
|
||||
[{:keys [db]}]
|
||||
(let [input (get-in db [:contacts/new-identity :input])]
|
||||
(re-frame/dispatch [:contacts/set-new-identity {:input input}])))
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns status-im.contexts.chat.messenger.messages.link-preview.events
|
||||
(:require
|
||||
[camel-snake-kebab.core :as csk]
|
||||
[status-im.contexts.profile.settings.events :as profile.settings.events]
|
||||
(:require [camel-snake-kebab.core :as csk]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.collection]
|
||||
[utils.re-frame :as rf]))
|
||||
|
@ -10,70 +9,57 @@
|
|||
[id]
|
||||
(str "https://status.app/c#" id))
|
||||
|
||||
(rf/defn cache-link-preview-data
|
||||
{:events [:chat.ui/cache-link-preview-data]}
|
||||
[{{:profile/keys [profile]} :db :as cofx} site data]
|
||||
(let [link-previews-cache (get profile :link-previews-cache {})]
|
||||
(profile.settings.events/optimistic-profile-update
|
||||
cofx
|
||||
:link-previews-cache
|
||||
(assoc link-previews-cache site (utils.collection/map-keys csk/->kebab-case-keyword data)))))
|
||||
(rf/reg-event-fx :chat.ui/cache-link-preview-data
|
||||
(fn [{:keys [db]} [site data]]
|
||||
(let [{:profile/keys [profile]} db
|
||||
link-previews-cache (-> profile
|
||||
(get :link-previews-cache {})
|
||||
(assoc site
|
||||
(utils.collection/map-keys csk/->kebab-case-keyword
|
||||
data)))]
|
||||
{:db (assoc-in db [:profile/profile :link-previews-cache] link-previews-cache)})))
|
||||
|
||||
(rf/defn load-link-preview-data
|
||||
{:events [:chat.ui/load-link-preview-data]}
|
||||
[{{:profile/keys [profile] :as db} :db} link]
|
||||
(rf/reg-event-fx :chat.ui/load-link-preview-data
|
||||
(fn [{{:profile/keys [profile]} :db} [link]]
|
||||
(let [{:keys [error] :as cache-data} (get-in profile [:link-previews-cache link])]
|
||||
(if (or (not cache-data) error)
|
||||
{:json-rpc/call [{:method "wakuext_getLinkPreviewData"
|
||||
(when (or (not cache-data) error)
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wakuext_getLinkPreviewData"
|
||||
:params [link]
|
||||
:on-success #(rf/dispatch [:chat.ui/cache-link-preview-data link %])
|
||||
:on-error #(rf/dispatch [:chat.ui/cache-link-preview-data link
|
||||
{:error (str "Can't get preview data for " link)}])}]}
|
||||
{:db db})))
|
||||
:on-success [:chat.ui/cache-link-preview-data link]
|
||||
:on-error [:chat.ui/cache-link-preview-data link
|
||||
{:error (str "Can't get preview data for " link)}]}]]]}))))
|
||||
|
||||
(rf/defn should-suggest-link-preview
|
||||
{:events [:chat.ui/should-suggest-link-preview]}
|
||||
[{:keys [db] :as cofx} enabled?]
|
||||
(profile.settings.events/profile-update
|
||||
cofx
|
||||
:link-preview-request-enabled
|
||||
(boolean enabled?)
|
||||
{}))
|
||||
(rf/reg-event-fx :chat.ui/should-suggest-link-preview
|
||||
(fn [_ [enabled?]]
|
||||
{:fx [[:dispatch
|
||||
[:profile.settings/profile-update :link-preview-request-enabled (boolean enabled?)]]]}))
|
||||
|
||||
(rf/defn save-link-preview-whitelist
|
||||
{:events [:chat.ui/link-preview-whitelist-received]}
|
||||
[{:keys [db]} whitelist]
|
||||
{:db (assoc db :link-previews-whitelist whitelist)})
|
||||
(rf/reg-event-fx :chat.ui/link-preview-whitelist-received
|
||||
(fn [{:keys [db]} [whitelist]]
|
||||
{:db (assoc db :link-previews-whitelist whitelist)}))
|
||||
|
||||
(rf/defn request-link-preview-whitelist
|
||||
[_]
|
||||
{:json-rpc/call [{:method "wakuext_getLinkPreviewWhitelist"
|
||||
(rf/reg-fx :chat.ui/request-link-preview-whitelist
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_getLinkPreviewWhitelist"
|
||||
:params []
|
||||
:on-success #(rf/dispatch [:chat.ui/link-preview-whitelist-received %])
|
||||
:on-error #(log/error "Failed to get link preview whitelist")}]})
|
||||
:on-success [:chat.ui/link-preview-whitelist-received]
|
||||
:on-error #(log/error "Failed to get link preview whitelist")})))
|
||||
|
||||
(defn cache-community-preview-data
|
||||
[{:keys [id] :as community}]
|
||||
(rf/dispatch [:chat.ui/cache-link-preview-data (community-link id) community]))
|
||||
|
||||
(rf/defn enable
|
||||
{:events [:chat.ui/enable-link-previews]}
|
||||
[{{:profile/keys [profile]} :db :as cofx} site enabled?]
|
||||
(profile.settings.events/profile-update
|
||||
cofx
|
||||
:link-previews-enabled-sites
|
||||
(if enabled?
|
||||
(rf/reg-event-fx :chat.ui/enable-link-previews
|
||||
(fn [{{:profile/keys [profile]} :db} [site enabled?]]
|
||||
(let [enabled-sites (if enabled?
|
||||
(conj (get profile :link-previews-enabled-sites #{}) site)
|
||||
(disj (get profile :link-previews-enabled-sites #{}) site))
|
||||
{}))
|
||||
(disj (get profile :link-previews-enabled-sites #{}) site))]
|
||||
{:fx [[:dispatch [:profile.settings/profile-update :link-previews-enabled-sites enabled-sites]]]})))
|
||||
|
||||
(rf/defn enable-all
|
||||
{:events [:chat.ui/enable-all-link-previews]}
|
||||
[cofx link-previews-whitelist enabled?]
|
||||
(profile.settings.events/profile-update
|
||||
cofx
|
||||
:link-previews-enabled-sites
|
||||
(if enabled?
|
||||
(rf/reg-event-fx :chat.ui/enable-all-link-previews
|
||||
(fn [_ [link-previews-whitelist enabled?]]
|
||||
(let [enabled-sites (if enabled?
|
||||
(into #{} (map :title link-previews-whitelist))
|
||||
#{})
|
||||
{}))
|
||||
#{})]
|
||||
{:fx [[:dispatch [:profile.settings/profile-update :link-previews-enabled-sites enabled-sites]]]})))
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
(:require
|
||||
[clojure.string :as string]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.config :as config]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(defn login
|
||||
|
@ -51,14 +51,14 @@
|
|||
(when path
|
||||
(string/replace-first path "file://" "")))
|
||||
|
||||
(rf/defn get-node-config-callback
|
||||
{:events [:profile.config/get-node-config-callback]}
|
||||
[{:keys [db]} node-config-json]
|
||||
(re-frame/reg-event-fx :profile.config/get-node-config-callback
|
||||
(fn [{:keys [db]} [node-config-json]]
|
||||
(let [node-config (transforms/json->clj node-config-json)]
|
||||
{:db (assoc-in db
|
||||
[:profile/profile :wakuv2-config]
|
||||
(get node-config :WakuV2Config))}))
|
||||
(get node-config :WakuV2Config))})))
|
||||
|
||||
(rf/defn get-node-config
|
||||
[_]
|
||||
(native-module/get-node-config #(rf/dispatch [:profile.config/get-node-config-callback %])))
|
||||
(re-frame/reg-fx :profile.config/get-node-config
|
||||
(fn []
|
||||
(native-module/get-node-config
|
||||
#(re-frame/dispatch [:profile.config/get-node-config-callback %]))))
|
||||
|
|
|
@ -2,37 +2,21 @@
|
|||
(:require
|
||||
[legacy.status-im.data-store.settings :as data-store.settings]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.contexts.profile.edit.accent-colour.events]
|
||||
[status-im.contexts.profile.edit.bio.events]
|
||||
[status-im.contexts.profile.edit.header.events]
|
||||
[status-im.contexts.profile.edit.name.events]
|
||||
[status-im.contexts.profile.login.events :as profile.login]
|
||||
status-im.contexts.profile.login.events
|
||||
[status-im.contexts.profile.rpc :as profile.rpc]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:profile/get-profiles-overview
|
||||
(fn [callback]
|
||||
(native-module/open-accounts callback)))
|
||||
|
||||
(rf/defn profile-selected
|
||||
{:events [:profile/profile-selected]}
|
||||
[{:keys [db]} key-uid]
|
||||
{:db (update db
|
||||
:profile/login
|
||||
#(-> %
|
||||
(defn- select-profile
|
||||
[profile key-uid]
|
||||
(-> profile
|
||||
(assoc :key-uid key-uid)
|
||||
(dissoc :error :password)))})
|
||||
(dissoc :error :password)))
|
||||
|
||||
(rf/defn init-profiles-overview
|
||||
[{:keys [db] :as cofx} profiles key-uid]
|
||||
(rf/merge cofx
|
||||
{:db (assoc db :profile/profiles-overview profiles)}
|
||||
(profile-selected key-uid)))
|
||||
|
||||
(defn reduce-profiles
|
||||
(defn- reduce-profiles
|
||||
[profiles]
|
||||
(reduce
|
||||
(fn [acc {:keys [key-uid] :as profile}]
|
||||
|
@ -40,28 +24,44 @@
|
|||
{}
|
||||
profiles))
|
||||
|
||||
(rf/defn get-profiles-overview-success
|
||||
{:events [:profile/get-profiles-overview-success]}
|
||||
[cofx profiles-overview]
|
||||
(rf/reg-fx
|
||||
:profile/get-profiles-overview
|
||||
(fn [callback]
|
||||
(native-module/open-accounts callback)))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:profile/profile-selected
|
||||
(fn [{:keys [db]} [key-uid]]
|
||||
{:db (update db :profile/login #(select-profile % key-uid))}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:profile/get-profiles-overview-success
|
||||
(fn [{:keys [db]} [profiles-overview]]
|
||||
(if (seq profiles-overview)
|
||||
(let [profiles (reduce-profiles profiles-overview)
|
||||
{:keys [key-uid]} (first (sort-by :timestamp > (vals profiles)))]
|
||||
(rf/merge cofx
|
||||
(navigation/init-root :profiles)
|
||||
(when key-uid (init-profiles-overview profiles key-uid))
|
||||
;;we check if biometric is available, and try to login with it,
|
||||
;;if succeed "node.login" signal will be triggered
|
||||
(when key-uid (profile.login/login-with-biometric-if-available key-uid))))
|
||||
(navigation/init-root cofx :intro)))
|
||||
{:db (if key-uid
|
||||
(-> db
|
||||
(assoc :profile/profiles-overview profiles)
|
||||
(update :profile/login #(select-profile % key-uid)))
|
||||
db)
|
||||
:fx [[:set-root :profiles]
|
||||
(when key-uid
|
||||
[:effects.biometric/check-if-available
|
||||
{:key-uid key-uid
|
||||
:on-success (fn [auth-method]
|
||||
(rf/dispatch [:profile.login/check-biometric-success key-uid
|
||||
auth-method]))}])]})
|
||||
{:fx [[:set-root :intro]]})))
|
||||
|
||||
(rf/defn update-setting-from-backup
|
||||
{:events [:profile/update-setting-from-backup]}
|
||||
[{:keys [db]} {:keys [backedUpSettings]}]
|
||||
(rf/reg-event-fx
|
||||
:profile/update-setting-from-backup
|
||||
(fn [{:keys [db]} [{:keys [backedUpSettings]}]]
|
||||
(let [setting (update backedUpSettings :name keyword)
|
||||
{:keys [name value]} (data-store.settings/rpc->setting-value setting)]
|
||||
{:db (assoc-in db [:profile/profile name] value)}))
|
||||
{:db (assoc-in db [:profile/profile name] value)})))
|
||||
|
||||
(rf/defn update-profile-from-backup
|
||||
{:events [:profile/update-profile-from-backup]}
|
||||
[_ {{:keys [ensUsernameDetails]} :backedUpProfile}]
|
||||
{:dispatch [:ens/update-usernames ensUsernameDetails]})
|
||||
(rf/reg-event-fx
|
||||
:profile/update-profile-from-backup
|
||||
(fn [_ [{{:keys [ensUsernameDetails]} :backedUpProfile}]]
|
||||
{:fx [[:dispatch [:ens/update-usernames ensUsernameDetails]]]}))
|
||||
|
|
|
@ -1,54 +1,29 @@
|
|||
(ns status-im.contexts.profile.login.events
|
||||
(:require
|
||||
[legacy.status-im.browser.core :as browser]
|
||||
[legacy.status-im.data-store.chats :as data-store.chats]
|
||||
[legacy.status-im.data-store.settings :as data-store.settings]
|
||||
[legacy.status-im.data-store.switcher-cards :as switcher-cards-store]
|
||||
[legacy.status-im.data-store.visibility-status-updates :as visibility-status-updates-store]
|
||||
[legacy.status-im.group-chats.core :as group-chats]
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
[legacy.status-im.mobile-sync-settings.core :as mobile-network]
|
||||
[legacy.status-im.pairing.core :as pairing]
|
||||
[legacy.status-im.stickers.core :as stickers]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.keychain.events :as keychain]
|
||||
[status-im.common.log :as logging]
|
||||
[status-im.common.universal-links :as universal-links]
|
||||
[status-im.config :as config]
|
||||
[status-im.contexts.chat.contacts.events :as contacts]
|
||||
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview]
|
||||
[status-im.contexts.profile.config :as profile.config]
|
||||
[status-im.constants :as constants]
|
||||
status-im.contexts.profile.login.effects
|
||||
[status-im.contexts.profile.push-notifications.events :as notifications]
|
||||
[status-im.contexts.profile.rpc :as profile.rpc]
|
||||
[status-im.contexts.profile.settings.events :as profile.settings.events]
|
||||
[status-im.contexts.shell.activity-center.events :as activity-center]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.security.core :as security]))
|
||||
|
||||
(rf/defn login
|
||||
{:events [:profile.login/login]}
|
||||
[{:keys [db]}]
|
||||
(rf/reg-event-fx :profile.login/login
|
||||
(fn [{:keys [db]}]
|
||||
(let [{:keys [key-uid password]} (:profile/login db)
|
||||
login-sha3-password (native-module/sha3 (security/safe-unmask-data password))]
|
||||
{:db (-> db
|
||||
(assoc-in [:profile/login :processing] true)
|
||||
(assoc-in [:syncing :login-sha3-password] login-sha3-password))
|
||||
:effects.profile/login [key-uid login-sha3-password]}))
|
||||
:fx [[:effects.profile/login [key-uid login-sha3-password]]]})))
|
||||
|
||||
(rf/defn biometrics-login
|
||||
{:events [:profile.login/biometrics-login]}
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [key-uid password]} (:profile/login db)]
|
||||
{:db (assoc-in db [:profile/login :processing] true)
|
||||
:effects.profile/login [key-uid (security/safe-unmask-data password)]}))
|
||||
|
||||
(rf/defn login-local-paired-user
|
||||
{:events [:profile.login/local-paired-user]}
|
||||
[{:keys [db]}]
|
||||
(rf/reg-event-fx :profile.login/local-paired-user
|
||||
(fn [{:keys [db]}]
|
||||
(let [{:keys [key-uid password]} (get-in db [:syncing :profile])
|
||||
login-sha3-password (get-in db [:syncing :login-sha3-password])
|
||||
password (if-not (nil? login-sha3-password) ;; already logged in
|
||||
|
@ -58,153 +33,156 @@
|
|||
{:db (-> db
|
||||
(assoc-in [:onboarding/profile :password] masked-password)
|
||||
(assoc-in [:onboarding/profile :syncing?] true))
|
||||
:effects.profile/login [key-uid password]}))
|
||||
:effects.profile/login [key-uid password]})))
|
||||
|
||||
(rf/defn redirect-to-root
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [pairing-completed? (= (get-in db [:syncing :pairing-status]) :completed)]
|
||||
(cond
|
||||
pairing-completed?
|
||||
{:db (dissoc db :syncing)
|
||||
:dispatch [:init-root :syncing-results]}
|
||||
|
||||
(get db :onboarding/new-account?)
|
||||
{:dispatch [:onboarding/finalize-setup]}
|
||||
|
||||
:else
|
||||
(rf/merge
|
||||
cofx
|
||||
(profile.settings.events/switch-theme nil :shell-stack)
|
||||
(navigation/init-root :shell-stack)))))
|
||||
|
||||
;; login phase 1, we want to load and show chats faster so we split login into 2 phases
|
||||
(rf/defn login-existing-profile
|
||||
[{:keys [db] :as cofx} settings account]
|
||||
;; login phase 1: we want to load and show chats faster, so we split login into 2 phases
|
||||
(rf/reg-event-fx :profile.login/login-existing-profile
|
||||
(fn [{:keys [db]} [settings account]]
|
||||
(let [{:networks/keys [current-network networks]
|
||||
:as settings}
|
||||
(data-store.settings/rpc->settings settings)
|
||||
profile-overview (profile.rpc/rpc->profiles-overview account)]
|
||||
(rf/merge cofx
|
||||
{:db (-> db
|
||||
profile-overview (profile.rpc/rpc->profiles-overview account)
|
||||
log-level (or (:log-level settings) config/log-level)
|
||||
pairing-completed? (= (get-in db [:syncing :pairing-status]) :completed)]
|
||||
{:db (cond-> (-> db
|
||||
(assoc :chats/loading? true
|
||||
:networks/current-network current-network
|
||||
:networks/networks (merge networks config/default-networks-by-id)
|
||||
:profile/profile (merge profile-overview settings)))
|
||||
:fx [[:dispatch [:universal-links/generate-profile-url]]
|
||||
:profile/profile (merge profile-overview
|
||||
settings
|
||||
{:log-level log-level}))
|
||||
(assoc-in [:activity-center :loading?] true))
|
||||
pairing-completed?
|
||||
(dissoc :syncing))
|
||||
:fx (into [[:dispatch [:universal-links/generate-profile-url]]
|
||||
[:dispatch [:community/fetch]]
|
||||
[:dispatch [:wallet/initialize]]]}
|
||||
(notifications/load-preferences)
|
||||
(data-store.chats/fetch-chats-preview
|
||||
{:on-success
|
||||
#(do (re-frame/dispatch [:chats-list/load-success %])
|
||||
[:dispatch [:wallet/initialize]]
|
||||
[:push-notifications/load-preferences]
|
||||
[:fetch-chats-preview
|
||||
{:on-success (fn [result]
|
||||
(rf/dispatch [:chats-list/load-success result])
|
||||
(rf/dispatch [:communities/get-user-requests-to-join])
|
||||
(re-frame/dispatch [:profile.login/get-chats-callback]))})
|
||||
(profile.config/get-node-config)
|
||||
(logging/set-log-level (:log-level settings))
|
||||
(activity-center/notifications-fetch-pending-contact-requests)
|
||||
(activity-center/update-seen-state)
|
||||
(activity-center/notifications-fetch-unread-count)
|
||||
(redirect-to-root))))
|
||||
(rf/dispatch [:profile.login/get-chats-callback]))}]
|
||||
[:profile.config/get-node-config]
|
||||
[:logs/set-level log-level]
|
||||
[:activity-center.notifications/fetch-pending-contact-requests-fx]
|
||||
[:activity-center/update-seen-state]
|
||||
[:activity-center.notifications/fetch-unread-count]]
|
||||
|
||||
;; login phase 2, we want to load and show chats faster so we split login into 2 phases
|
||||
(rf/defn get-chats-callback
|
||||
{:events [:profile.login/get-chats-callback]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(cond
|
||||
pairing-completed?
|
||||
[[:set-root :syncing-results]]
|
||||
|
||||
(get db :onboarding/new-account?)
|
||||
[[:dispatch [:onboarding/finalize-setup]]]
|
||||
|
||||
:else
|
||||
[[:profile.settings/switch-theme-fx
|
||||
[(or (get-in db [:profile/profile :appearance])
|
||||
constants/theme-type-dark)
|
||||
:shell-stack
|
||||
false]]
|
||||
[:set-root :shell-stack]]))})))
|
||||
|
||||
;; login phase 2: we want to load and show chats faster, so we split login into 2 phases
|
||||
(rf/reg-event-fx :profile.login/get-chats-callback
|
||||
(fn [{:keys [db]}]
|
||||
(let [{:networks/keys [current-network networks]} db
|
||||
{:keys [notifications-enabled?]} (:profile/profile db)
|
||||
current-network-config (get networks current-network)
|
||||
{:keys [notifications-enabled? key-uid
|
||||
preview-privacy?]} (:profile/profile db)
|
||||
network-id (str (get-in networks
|
||||
[current-network :config :NetworkId]))]
|
||||
(rf/merge
|
||||
cofx
|
||||
(cond-> {:json-rpc/call [{:method "wakuext_startMessenger"
|
||||
:on-success #(re-frame/dispatch
|
||||
[:messenger-started %])
|
||||
{:db db
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "wakuext_startMessenger"
|
||||
:on-success [:profile.login/messenger-started]
|
||||
:on-error #(log/error
|
||||
"failed to start messenger")}]
|
||||
:check-eip1559-activation {:network-id network-id}
|
||||
:effects.profile/enable-local-notifications nil}
|
||||
(not (:universal-links/handling db))
|
||||
(assoc :effects.chat/open-last-chat (get-in db [:profile/profile :key-uid]))
|
||||
notifications-enabled?
|
||||
(assoc :effects/push-notifications-enable nil))
|
||||
(contacts/initialize-contacts)
|
||||
(browser/initialize-browser)
|
||||
(mobile-network/on-network-status-change)
|
||||
(group-chats/get-group-chat-invitations)
|
||||
(profile.settings.events/get-profile-picture)
|
||||
(profile.settings.events/change-preview-privacy)
|
||||
(link-preview/request-link-preview-whitelist)
|
||||
(visibility-status-updates-store/fetch-visibility-status-updates-rpc)
|
||||
(switcher-cards-store/fetch-switcher-cards-rpc))))
|
||||
"failed to start messenger")}]]
|
||||
[:check-eip1559-activation {:network-id network-id}]
|
||||
[:effects.profile/enable-local-notifications]
|
||||
[:contacts/initialize-contacts]
|
||||
[:browser/initialize-browser]
|
||||
[:dispatch [:mobile-network/on-network-status-change]]
|
||||
[:group-chats/get-group-chat-invitations]
|
||||
[:profile.settings/get-profile-picture key-uid]
|
||||
[:profile.settings/blank-preview-flag-changed preview-privacy?]
|
||||
[:chat.ui/request-link-preview-whitelist]
|
||||
[:visibility-status-updates/fetch]
|
||||
[:switcher-cards/fetch]
|
||||
(when-not (:universal-links/handling db)
|
||||
[:effects.chat/open-last-chat key-uid])
|
||||
(when notifications-enabled?
|
||||
[:effects/push-notifications-enable])]})))
|
||||
|
||||
(rf/defn messenger-started
|
||||
{:events [:messenger-started]}
|
||||
[{:keys [db] :as cofx} {:keys [mailservers] :as response}]
|
||||
(log/info "Messenger started")
|
||||
(let [new-account? (get db :onboarding/new-account?)]
|
||||
(rf/merge cofx
|
||||
(rf/reg-event-fx :profile.login/messenger-started
|
||||
(fn [{:keys [db]} [{:keys [mailservers]}]]
|
||||
(let [chain-id (chain/chain-id db)
|
||||
new-account? (get db :onboarding/new-account?)]
|
||||
{:db (-> db
|
||||
(assoc :messenger/started? true)
|
||||
(mailserver/add-mailservers mailservers))
|
||||
:json-rpc/call [{:method "admin_nodeInfo"
|
||||
:on-success #(re-frame/dispatch [:node-info-fetched %])
|
||||
:on-error #(log/error "node-info: failed error" %)}]}
|
||||
(pairing/init)
|
||||
(stickers/load-packs)
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "admin_nodeInfo"
|
||||
:on-success [:profile.login/node-info-fetched]
|
||||
:on-error #(log/error "node-info: failed error" %)}]]
|
||||
[:pairing/get-our-installations]
|
||||
[:stickers/load-packs chain-id]
|
||||
(when-not new-account?
|
||||
(universal-links/process-stored-event)))))
|
||||
[:dispatch [:universal-links/process-stored-event]])]})))
|
||||
|
||||
(rf/defn set-node-info
|
||||
{:events [:node-info-fetched]}
|
||||
[{:keys [db]} node-info]
|
||||
{:db (assoc db :node-info node-info)})
|
||||
(rf/reg-event-fx :profile.login/node-info-fetched
|
||||
(fn [{:keys [db]} [node-info]]
|
||||
{:db (assoc db :node-info node-info)}))
|
||||
|
||||
(rf/defn login-node-signal
|
||||
[{{:onboarding/keys [recovered-account? new-account?] :as db} :db :as cofx}
|
||||
{:keys [settings account ensUsernames error]}]
|
||||
(rf/reg-event-fx
|
||||
:profile.login/login-node-signal
|
||||
(fn [{{:onboarding/keys [recovered-account? new-account?] :as db} :db}
|
||||
[{:keys [settings account ensUsernames error]}]]
|
||||
(log/debug "[signals] node.login" "error" error)
|
||||
(if error
|
||||
{:db (update db :profile/login #(-> % (dissoc :processing) (assoc :error error)))}
|
||||
(rf/merge cofx
|
||||
{:db (dissoc db :profile/login)
|
||||
:dispatch-n [[:logging/initialize-web3-client-version]
|
||||
:fx [[:logging/initialize-web3-client-version]
|
||||
(when (and new-account? (not recovered-account?))
|
||||
[:wallet-legacy/set-initial-blocks-range])
|
||||
[:ens/update-usernames ensUsernames]]}
|
||||
(login-existing-profile settings account))))
|
||||
[:dispatch [:wallet-legacy/set-initial-blocks-range]])
|
||||
[:dispatch [:ens/update-usernames ensUsernames]]
|
||||
[:dispatch [:profile.login/login-existing-profile settings account]]]})))
|
||||
|
||||
(rf/defn login-with-biometric-if-available
|
||||
{:events [:profile.login/login-with-biometric-if-available]}
|
||||
[_ key-uid]
|
||||
{:effects.biometric/check-if-available {:key-uid key-uid
|
||||
(rf/reg-event-fx
|
||||
:profile.login/login-with-biometric-if-available
|
||||
(fn [_ [key-uid]]
|
||||
{:fx [[:effects.biometric/check-if-available
|
||||
{:key-uid key-uid
|
||||
:on-success (fn [auth-method]
|
||||
(rf/dispatch
|
||||
[:profile.login/check-biometric-success
|
||||
key-uid auth-method]))}})
|
||||
key-uid auth-method]))}]]}))
|
||||
|
||||
(rf/defn check-biometric-success
|
||||
{:events [:profile.login/check-biometric-success]}
|
||||
[{:keys [db]} key-uid auth-method]
|
||||
(merge {:db (assoc db :auth-method auth-method)}
|
||||
(when (= auth-method keychain/auth-method-biometric)
|
||||
{:keychain/password-hash-migration
|
||||
(rf/reg-event-fx
|
||||
:profile.login/check-biometric-success
|
||||
(fn [{:keys [db]} [key-uid auth-method]]
|
||||
{:db (assoc db :auth-method auth-method)
|
||||
:fx [(when (= auth-method keychain/auth-method-biometric)
|
||||
[:keychain/password-hash-migration
|
||||
{:key-uid key-uid
|
||||
:callback (fn []
|
||||
(rf/dispatch [:biometric/authenticate
|
||||
{:on-success #(rf/dispatch [:profile.login/biometric-success])
|
||||
(rf/dispatch
|
||||
[:biometric/authenticate
|
||||
{:on-success #(rf/dispatch
|
||||
[:profile.login/biometric-success])
|
||||
:on-fail #(rf/dispatch
|
||||
[:profile.login/biometric-auth-fail %])}]))}})))
|
||||
[:profile.login/biometric-auth-fail %])}]))}])]}))
|
||||
|
||||
(rf/defn get-user-password-success
|
||||
{:events [:profile.login/get-user-password-success]}
|
||||
[{:keys [db] :as cofx} password]
|
||||
(rf/reg-event-fx
|
||||
:profile.login/get-user-password-success
|
||||
(fn [{:keys [db]} [password]]
|
||||
(when password
|
||||
(rf/merge
|
||||
cofx
|
||||
{:db (assoc-in db [:profile/login :password] password)}
|
||||
(navigation/init-root :progress)
|
||||
(biometrics-login))))
|
||||
(let [{:keys [key-uid password]} (:profile/login db)]
|
||||
{:db (-> db
|
||||
(assoc-in [:profile/login :password] password)
|
||||
(assoc-in [:profile/login :processing] true))
|
||||
:fx [[:set-root :progress]
|
||||
[:effects.profile/login [key-uid (security/safe-unmask-data password)]]]}))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:profile.login/biometric-success
|
||||
|
@ -223,20 +201,20 @@
|
|||
:event :profile.login/biometric-auth-fail)))
|
||||
{:dispatch [:biometric/show-message (ex-cause error)]}))
|
||||
|
||||
(rf/defn verify-database-password
|
||||
{:events [:profile.login/verify-database-password]}
|
||||
[_ entered-password cb]
|
||||
(rf/reg-event-fx
|
||||
:profile.login/verify-database-password
|
||||
(fn [_ [entered-password cb]]
|
||||
(let [hashed-password (-> entered-password
|
||||
security/safe-unmask-data
|
||||
native-module/sha3)]
|
||||
{:json-rpc/call [{:method "accounts_verifyPassword"
|
||||
:params [hashed-password]
|
||||
:on-success #(rf/dispatch [:profile.login/verified-database-password % cb])
|
||||
:on-error #(log/error "accounts_verifyPassword error" %)}]}))
|
||||
:on-error #(log/error "accounts_verifyPassword error" %)}]})))
|
||||
|
||||
(rf/defn verify-database-password-success
|
||||
{:events [:profile.login/verified-database-password]}
|
||||
[{:keys [db]} valid? callback]
|
||||
(rf/reg-event-fx
|
||||
:profile.login/verified-database-password
|
||||
(fn [{:keys [db]} [valid? callback]]
|
||||
(if valid?
|
||||
(do
|
||||
(when (fn? callback)
|
||||
|
@ -249,9 +227,9 @@
|
|||
:profile/login
|
||||
#(-> %
|
||||
(dissoc :processing)
|
||||
(assoc :error "Invalid password")))}))
|
||||
(assoc :error "Invalid password")))})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
(rf/reg-event-fx
|
||||
:profile/on-password-input-changed
|
||||
(fn [{:keys [db]} [{:keys [password error]}]]
|
||||
{:db (update db :profile/login assoc :password password :error error)}))
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
(:require
|
||||
[cljs-bean.core :as bean]
|
||||
[native-module.push-notifications :as native-module.pn]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.async-storage :as async-storage]
|
||||
[react-native.platform :as platform]
|
||||
[react-native.push-notification-ios :as pn-ios]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.config :as config]
|
||||
status-im.contexts.profile.push-notifications.effects
|
||||
[taoensso.timbre :as log]
|
||||
|
@ -55,8 +57,8 @@
|
|||
[{:keys [db]} preferences]
|
||||
{:db (assoc db :push-notifications/preferences preferences)})
|
||||
|
||||
(rf/defn load-preferences
|
||||
[_]
|
||||
{:json-rpc/call [{:method "localnotifications_notificationPreferences"
|
||||
(re-frame/reg-fx :push-notifications/load-preferences
|
||||
(fn []
|
||||
(json-rpc/call {:method "localnotifications_notificationPreferences"
|
||||
:params []
|
||||
:on-success #(rf/dispatch [:push-notifications/preferences-loaded %])}]})
|
||||
:on-success [:push-notifications/preferences-loaded]})))
|
||||
|
|
|
@ -1,63 +1,47 @@
|
|||
(ns status-im.contexts.profile.settings.events
|
||||
(:require [clojure.string :as string]
|
||||
[legacy.status-im.bottom-sheet.events :as bottom-sheet.events]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.constants :as constants]
|
||||
status-im.contexts.profile.settings.effects
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/defn send-contact-update
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [name preferred-name display-name]} (:profile/profile db)]
|
||||
{:json-rpc/call [{:method "wakuext_sendContactUpdates"
|
||||
:params [(or preferred-name display-name name) ""]
|
||||
:on-success #(log/debug "sent contact update")}]}))
|
||||
|
||||
(rf/defn profile-update
|
||||
{:events [:profile.settings/profile-update]}
|
||||
[{:keys [db] :as cofx}
|
||||
setting setting-value
|
||||
{:keys [dont-sync? on-success] :or {on-success #()}}]
|
||||
(rf/merge
|
||||
cofx
|
||||
{:db (if setting-value
|
||||
(defn- set-setting-value
|
||||
[db setting setting-value]
|
||||
(if setting-value
|
||||
(assoc-in db [:profile/profile setting] setting-value)
|
||||
(update db :profile/profile dissoc setting))
|
||||
:json-rpc/call
|
||||
(update db :profile/profile dissoc setting)))
|
||||
|
||||
(rf/reg-event-fx :profile.settings/profile-update
|
||||
(fn [{:keys [db]} [setting setting-value {:keys [dont-sync? on-success]}]]
|
||||
{:db (-> db
|
||||
(set-setting-value setting setting-value))
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "settings_saveSetting"
|
||||
:params [setting setting-value]
|
||||
:on-success on-success}]}
|
||||
:on-success on-success}]]
|
||||
|
||||
(when (#{:name :preferred-name} setting)
|
||||
(constantly {:profile/get-profiles-overview #(rf/dispatch [:multiaccounts.ui/update-name %])}))
|
||||
[:profile/get-profiles-overview #(rf/dispatch [:multiaccounts.ui/update-name %])])
|
||||
|
||||
(when (and (not dont-sync?) (#{:name :preferred-name} setting))
|
||||
(send-contact-update))))
|
||||
(let [{:keys [name preferred-name display-name]} (:profile/profile db)]
|
||||
[:json-rpc/call
|
||||
[{:method "wakuext_sendContactUpdates"
|
||||
:params [(or preferred-name display-name name) ""]
|
||||
:on-success #(log/debug "sent contact update")}]]))]}))
|
||||
|
||||
(rf/defn optimistic-profile-update
|
||||
[{:keys [db]} setting setting-value]
|
||||
{:db (if setting-value
|
||||
(assoc-in db [:profile/profile setting] setting-value)
|
||||
(update db :profile/profile dissoc setting))})
|
||||
|
||||
(rf/defn change-preview-privacy
|
||||
[{:keys [db]}]
|
||||
(rf/reg-event-fx :profile.settings/change-preview-privacy
|
||||
(fn [{:keys [db]}]
|
||||
(let [private? (get-in db [:profile/profile :preview-privacy?])]
|
||||
{:profile.settings/blank-preview-flag-changed private?}))
|
||||
{:fx [[:profile.settings/blank-preview-flag-changed private?]]})))
|
||||
|
||||
(rf/defn update-value
|
||||
{:events [:profile.settings/update-value]}
|
||||
[cofx key value]
|
||||
(profile-update cofx key value {}))
|
||||
|
||||
(rf/defn change-webview-debug
|
||||
{:events [:profile.settings/change-webview-debug]}
|
||||
[{:keys [db] :as cofx} value]
|
||||
(rf/merge cofx
|
||||
{:profile.settings/webview-debug-changed value}
|
||||
(profile-update :webview-debug (boolean value) {})))
|
||||
(rf/reg-event-fx :profile.settings/change-webview-debug
|
||||
(fn [_ [value]]
|
||||
(let [value' (boolean value)]
|
||||
{:fx [[:dispatch [:profile.settings/profile-update :webview-debug value']]
|
||||
[:profile.settings/webview-debug-changed value']]})))
|
||||
|
||||
(rf/reg-event-fx :profile.settings/toggle-test-networks
|
||||
(fn [{:keys [db]}]
|
||||
|
@ -82,17 +66,22 @@
|
|||
{:on-success on-success}])
|
||||
:on-cancel nil}]]})))
|
||||
|
||||
(rf/defn change-preview-privacy-flag
|
||||
{:events [:profile.settings/change-preview-privacy]}
|
||||
[{:keys [db] :as cofx} private?]
|
||||
(rf/merge cofx
|
||||
{:profile.settings/blank-preview-flag-changed private?}
|
||||
(profile-update
|
||||
:preview-privacy?
|
||||
(boolean private?)
|
||||
{})))
|
||||
(rf/reg-event-fx :profile.settings/change-preview-privacy
|
||||
(fn [_ [private?]]
|
||||
(let [private?' (boolean private?)]
|
||||
{:fx [[:dispatch [:profile.settings/profile-update :preview-privacy? private?']]
|
||||
[:profile.settings/blank-preview-flag-changed private?']]})))
|
||||
|
||||
(re-frame/reg-event-fx :profile.settings/toggle-peer-syncing
|
||||
(rf/reg-event-fx :profile.settings/change-profile-pictures-show-to
|
||||
(fn [{:keys [db]} [id]]
|
||||
{:db (-> db
|
||||
(assoc-in [:profile/profile :profile-pictures-show-to] id))
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "wakuext_changeIdentityImageShowTo"
|
||||
:params [id]
|
||||
:on-success #(log/debug "picture settings changed successfully")}]]]}))
|
||||
|
||||
(rf/reg-event-fx :profile.settings/toggle-peer-syncing
|
||||
(fn [{:keys [db]}]
|
||||
(let [value (get-in db [:profile/profile :peer-syncing-enabled?])
|
||||
new-value (not value)]
|
||||
|
@ -102,81 +91,69 @@
|
|||
:params [{:enabled new-value}]
|
||||
:on-error #(log/error "failed to toggle peer syncing" new-value %)}]]]})))
|
||||
|
||||
(rf/defn change-profile-pictures-show-to
|
||||
{:events [:profile.settings/change-profile-pictures-show-to]}
|
||||
[cofx id]
|
||||
(rf/merge cofx
|
||||
{:json-rpc/call [{:method "wakuext_changeIdentityImageShowTo"
|
||||
:params [id]
|
||||
:on-success #(log/debug "picture settings changed successfully")}]}
|
||||
(optimistic-profile-update :profile-pictures-show-to id)))
|
||||
(rf/reg-event-fx :profile.settings/change-appearance
|
||||
(fn [_ [theme]]
|
||||
{:fx [[:dispatch [:profile.settings/profile-update :appearance theme]]
|
||||
[:profile.settings/switch-theme-fx [theme :appearance true]]]}))
|
||||
|
||||
(rf/defn change-appearance
|
||||
{:events [:profile.settings/change-appearance]}
|
||||
[cofx theme]
|
||||
(rf/merge cofx
|
||||
{:profile.settings/switch-theme-fx [theme :appearance true]}
|
||||
(profile-update :appearance theme {})))
|
||||
|
||||
(rf/defn switch-theme
|
||||
{:events [:profile.settings/switch-theme]}
|
||||
[cofx theme view-id]
|
||||
(rf/reg-event-fx :profile.settings/switch-theme
|
||||
(fn [{:keys [db]} [theme view-id]]
|
||||
(let [theme (or theme
|
||||
(get-in cofx [:db :profile/profile :appearance])
|
||||
(get-in db [:profile/profile :appearance])
|
||||
constants/theme-type-dark)]
|
||||
{:profile.settings/switch-theme-fx [theme view-id false]}))
|
||||
{:fx [[:profile.settings/switch-theme-fx [theme view-id false]]]})))
|
||||
|
||||
(rf/defn get-profile-picture
|
||||
{:events [:profile.settings/get-profile-picture]}
|
||||
[cofx]
|
||||
(let [key-uid (get-in cofx [:db :profile/profile :key-uid])]
|
||||
{:json-rpc/call [{:method "multiaccounts_getIdentityImages"
|
||||
(rf/reg-fx :profile.settings/get-profile-picture
|
||||
(fn [key-uid]
|
||||
(json-rpc/call {:method "multiaccounts_getIdentityImages"
|
||||
:params [key-uid]
|
||||
:on-success [:profile.settings/update-local-picture]}]}))
|
||||
:on-success [:profile.settings/update-local-picture]})))
|
||||
|
||||
(rf/defn save-profile-picture
|
||||
{:events [:profile.settings/save-profile-picture]}
|
||||
[cofx path ax ay bx by]
|
||||
(let [key-uid (get-in cofx [:db :profile/profile :key-uid])]
|
||||
(rf/merge cofx
|
||||
{:json-rpc/call [{:method "multiaccounts_storeIdentityImage"
|
||||
(rf/reg-event-fx :profile.settings/save-profile-picture
|
||||
(fn [{:keys [db]} [path ax ay bx by]]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])]
|
||||
{:db (-> db
|
||||
(assoc :bottom-sheet/show? false))
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "multiaccounts_storeIdentityImage"
|
||||
:params [key-uid (string/replace-first path #"file://" "") ax ay bx
|
||||
by]
|
||||
:on-success [:profile.settings/update-local-picture]}]}
|
||||
(bottom-sheet.events/hide-bottom-sheet-old))))
|
||||
:on-success [:profile.settings/update-local-picture]}]]
|
||||
[:dismiss-bottom-sheet-overlay-old]]})))
|
||||
|
||||
(rf/defn save-profile-picture-from-url
|
||||
{:events [:profile.settings/save-profile-picture-from-url]}
|
||||
[cofx url]
|
||||
(let [key-uid (get-in cofx [:db :profile/profile :key-uid])]
|
||||
(rf/merge cofx
|
||||
{:json-rpc/call [{:method "multiaccounts_storeIdentityImageFromURL"
|
||||
(rf/reg-event-fx :profile.settings/save-profile-picture-from-url
|
||||
(fn [{:keys [db]} [url]]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])]
|
||||
{:db (-> db
|
||||
(assoc :bottom-sheet/show? false))
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "multiaccounts_storeIdentityImageFromURL"
|
||||
:params [key-uid url]
|
||||
:on-error #(log/error "::save-profile-picture-from-url error" %)
|
||||
:on-success [:profile.settings/update-local-picture]}]}
|
||||
(bottom-sheet.events/hide-bottom-sheet-old))))
|
||||
:on-success [:profile.settings/update-local-picture]}]]
|
||||
[:dismiss-bottom-sheet-overlay-old]]})))
|
||||
|
||||
(rf/defn delete-profile-picture
|
||||
{:events [:profile.settings/delete-profile-picture]}
|
||||
[cofx name]
|
||||
(let [key-uid (get-in cofx [:db :profile/profile :key-uid])]
|
||||
(rf/merge cofx
|
||||
{:json-rpc/call [{:method "multiaccounts_deleteIdentityImage"
|
||||
(rf/reg-event-fx :profile.settings/delete-profile-picture
|
||||
(fn [{:keys [db]}]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])]
|
||||
{:db (-> db
|
||||
(update :profile/profile dissoc :images)
|
||||
(assoc :bottom-sheet/show? false))
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "multiaccounts_deleteIdentityImage"
|
||||
:params [key-uid]
|
||||
;; NOTE: In case of an error we could fallback to previous image in
|
||||
;; UI with a toast error
|
||||
:on-success #(log/info "[profile] Delete profile image" %)}]}
|
||||
(optimistic-profile-update :images nil)
|
||||
(bottom-sheet.events/hide-bottom-sheet-old))))
|
||||
:on-success #(log/info "[profile] Delete profile image" %)}]]
|
||||
[:dismiss-bottom-sheet-overlay-old]]})))
|
||||
|
||||
(rf/defn store-profile-picture
|
||||
{:events [:profile.settings/update-local-picture]}
|
||||
[cofx pics]
|
||||
(optimistic-profile-update cofx :images pics))
|
||||
(rf/reg-event-fx :profile.settings/update-local-picture
|
||||
(fn [{:keys [db]} [images]]
|
||||
{:db (assoc-in db [:profile/profile :images] images)}))
|
||||
|
||||
(rf/defn mark-mnemonic-as-shown
|
||||
{:events [:profile.settings/mnemonic-was-shown]}
|
||||
[cofx]
|
||||
{:json-rpc/call [{:method "settings_mnemonicWasShown"
|
||||
(rf/reg-event-fx :profile.settings/mnemonic-was-shown
|
||||
(fn [_]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "settings_mnemonicWasShown"
|
||||
:on-success #(log/debug "mnemonic was marked as shown")
|
||||
:on-error #(log/error "mnemonic was not marked as shown" %)}]})
|
||||
:on-error #(log/error "mnemonic was not marked as shown" %)}]]]}))
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
[legacy.status-im.data-store.chats :as data-store.chats]
|
||||
[quo.foundations.colors :as colors]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.common.toasts.events :as toasts]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.shell.activity-center.notification-types :as types]
|
||||
|
@ -408,6 +409,17 @@
|
|||
(constantly processed)
|
||||
#(concat % processed))))}))
|
||||
|
||||
(re-frame/reg-fx :activity-center.notifications/fetch-pending-contact-requests-fx
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_activityCenterNotifications"
|
||||
:params [{:cursor start-or-end-cursor
|
||||
:limit 20
|
||||
:activityTypes [types/contact-request]
|
||||
:readType (->rpc-read-type :unread)}]
|
||||
:on-success [:activity-center.notifications/fetch-pending-contact-requests-success]
|
||||
:on-error [:activity-center.notifications/fetch-error types/contact-request
|
||||
:unread]})))
|
||||
|
||||
(rf/defn notifications-fetch-pending-contact-requests
|
||||
"Unread contact requests are, in practical terms, the same as pending contact
|
||||
requests in the Activity Center, because pending contact requests are always
|
||||
|
@ -419,14 +431,7 @@
|
|||
{:events [:activity-center.notifications/fetch-pending-contact-requests]}
|
||||
[{:keys [db]}]
|
||||
{:db (assoc-in db [:activity-center :loading?] true)
|
||||
:json-rpc/call
|
||||
[{:method "wakuext_activityCenterNotifications"
|
||||
:params [{:cursor start-or-end-cursor
|
||||
:limit 20
|
||||
:activityTypes [types/contact-request]
|
||||
:readType (->rpc-read-type :unread)}]
|
||||
:on-success [:activity-center.notifications/fetch-pending-contact-requests-success]
|
||||
:on-error [:activity-center.notifications/fetch-error types/contact-request :unread]}]})
|
||||
:fx [[:activity-center.notifications/fetch-pending-contact-requests-fx]]})
|
||||
|
||||
(rf/defn notifications-fetch-pending-contact-requests-success
|
||||
{:events [:activity-center.notifications/fetch-pending-contact-requests-success]}
|
||||
|
@ -448,14 +453,12 @@
|
|||
|
||||
;;;; Unread counters
|
||||
|
||||
(rf/defn update-seen-state
|
||||
{:events [:activity-center/update-seen-state]}
|
||||
[_]
|
||||
{:json-rpc/call
|
||||
[{:method "wakuext_hasUnseenActivityCenterNotifications"
|
||||
(re-frame/reg-fx :activity-center/update-seen-state
|
||||
(fn []
|
||||
(json-rpc/call [{:method "wakuext_hasUnseenActivityCenterNotifications"
|
||||
:params []
|
||||
:on-success [:activity-center/update-seen-state-success]
|
||||
:on-error [:activity-center/update-seen-state-error]}]})
|
||||
:on-error [:activity-center/update-seen-state-error]}])))
|
||||
|
||||
(rf/defn update-seen-state-success
|
||||
{:events [:activity-center/update-seen-state-success]}
|
||||
|
@ -492,6 +495,14 @@
|
|||
{:error error
|
||||
:event :activity-center/mark-as-seen}))
|
||||
|
||||
(re-frame/reg-fx :activity-center.notifications/fetch-unread-count
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_activityCenterNotificationsCount"
|
||||
:params [{:activityTypes types/all-supported
|
||||
:readType (->rpc-read-type :unread)}]
|
||||
:on-success [:activity-center.notifications/fetch-unread-count-success]
|
||||
:on-error [:activity-center.notifications/fetch-unread-count-error]})))
|
||||
|
||||
(rf/defn notifications-fetch-unread-count
|
||||
{:events [:activity-center.notifications/fetch-unread-count]}
|
||||
[_]
|
||||
|
|
|
@ -8,13 +8,17 @@
|
|||
status-im.common.emoji-picker.events
|
||||
status-im.common.font.events
|
||||
[status-im.common.json-rpc.events]
|
||||
status-im.common.log
|
||||
status-im.common.password-authentication.events
|
||||
status-im.common.signals.events
|
||||
status-im.common.theme.events
|
||||
[status-im.common.toasts.events]
|
||||
status-im.common.universal-links
|
||||
status-im.contexts.chat.contacts.events
|
||||
status-im.contexts.chat.events
|
||||
[status-im.contexts.chat.home.add-new-contact.events]
|
||||
status-im.contexts.chat.messenger.composer.events
|
||||
status-im.contexts.chat.messenger.messages.link-preview.events
|
||||
status-im.contexts.chat.messenger.photo-selector.events
|
||||
status-im.contexts.communities.events
|
||||
status-im.contexts.communities.overview.events
|
||||
|
@ -29,6 +33,7 @@
|
|||
status-im.contexts.wallet.send.events
|
||||
status-im.contexts.wallet.signals
|
||||
[status-im.db :as db]
|
||||
status-im.navigation.events
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/defn start-app
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
(p/resolved ::messenger-started)
|
||||
(do
|
||||
(create-multiaccount!)
|
||||
(-> (wait-for [:messenger-started])
|
||||
(-> (wait-for [:profile.login/messenger-started])
|
||||
(.then #(assert-messenger-started))))))
|
||||
|
||||
(defn test-async
|
||||
|
|
Loading…
Reference in New Issue