fix: nav conflicts when return from bg from link (#17853)

This commit is contained in:
yqrashawn 2023-11-10 09:15:02 +08:00 committed by GitHub
parent ffeb06f36c
commit b4919261cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 11 deletions

View File

@ -18,12 +18,14 @@
(log/error e))))
(defn set-item!
[k value]
(-> ^js async-storage
(.setItem (str k)
(clj->transit value))
(.catch (fn [error]
(log/error "[async-storage]" error)))))
([k value] (set-item! k value identity))
([k value cb]
(-> ^js async-storage
(.setItem (str k)
(clj->transit value))
(.then (fn [_] (cb)))
(.catch (fn [error]
(log/error "[async-storage]" error))))))
(defn set-item-factory
[]

View File

@ -158,7 +158,9 @@
(rf/defn on-going-in-background
[{:keys [db now]}]
{:db (assoc db :app-in-background-since now)})
{:db (-> db
(assoc :app-in-background-since now)
(dissoc :universal-links/handling))})
;; event not implemented
;; :dispatch-n [[:audio-recorder/on-background] [:audio-message/on-background]]

View File

@ -3,6 +3,7 @@
[clojure.string :as string]
[native-module.core :as native-module]
[re-frame.core :as re-frame]
[react-native.async-storage :as async-storage]
[react-native.core :as rn]
[status-im2.navigation.events :as navigation]
[taoensso.timbre :as log]
@ -118,7 +119,10 @@
"Dispatch url so we can get access to re-frame/db"
[url]
(if-not (nil? url)
(re-frame/dispatch [:universal-links/handle-url url])
(do
(async-storage/set-item! (str :chat-id) nil #(rf/dispatch [:universal-links/remove-handling]))
(re-frame/dispatch [:universal-links/handling])
(re-frame/dispatch [:universal-links/handle-url url]))
(log/debug "universal-links: no url")))
(rf/defn on-handle
@ -151,6 +155,16 @@
(log/info :store-url-for-later)
{:db (assoc db :universal-links/url url)})
(rf/defn handling
{:events [:universal-links/handling]}
[{:keys [db]}]
{:db (assoc db :universal-links/handling true)})
(rf/defn remove-handling
{:events [:universal-links/remove-handling]}
[{:keys [db]}]
{:db (dissoc db :universal-links/handling)})
(rf/defn handle-url
"Store url in the database if the user is not logged in, to be processed
on login, otherwise just handle it."

View File

@ -113,8 +113,9 @@
(fn [accounts tokens custom-tokens favourites]
(re-frame/dispatch [:wallet-legacy/initialize-wallet
accounts tokens custom-tokens favourites]))]
:check-eip1559-activation {:network-id network-id}
:chat/open-last-chat (get-in db [:profile/profile :key-uid])}
:check-eip1559-activation {:network-id network-id}}
(not (:universal-links/handling db))
(assoc :chat/open-last-chat (get-in db [:profile/profile :key-uid]))
notifications-enabled?
(assoc :effects/push-notifications-enable nil))
(transport/start-messenger)

View File

@ -20,8 +20,9 @@
(defn handle-notification-press
[{{deep-link :deepLink} :userInfo
interaction :userInteraction}]
(async-storage/set-item! (str :chat-id) nil)
(async-storage/set-item! (str :chat-id) nil #(rf/dispatch [:universal-links/remove-handling]))
(when (and deep-link (or platform/ios? (and platform/android? interaction)))
(rf/dispatch [:universal-links/handling])
(rf/dispatch [:universal-links/handle-url deep-link])))
(defn listen-notifications