mirror of
https://github.com/status-im/status-mobile.git
synced 2025-02-04 12:55:03 +00:00
[#12782] Re-open app on the last open chat
This commit is contained in:
parent
cd111aeeec
commit
646add59b8
@ -9,7 +9,7 @@
|
||||
|
||||
(def key->string str)
|
||||
|
||||
(defn- set-item! [key value]
|
||||
(defn set-item! [key value]
|
||||
(-> ^js async-storage
|
||||
(.setItem (key->string key)
|
||||
(clj->transit value))
|
||||
|
@ -1,65 +1,64 @@
|
||||
(ns status-im.events
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.chat.models :as chat]
|
||||
[status-im.i18n.i18n :as i18n]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.multiaccounts.core :as multiaccounts]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.utils.fx :as fx]
|
||||
status-im.utils.logging.core
|
||||
status-im.backup.core
|
||||
[status-im.wallet.core :as wallet]
|
||||
[status-im.keycard.core :as keycard]
|
||||
[status-im.utils.dimensions :as dimensions]
|
||||
[status-im.multiaccounts.biometric.core :as biometric]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.components.permissions :as permissions]
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.anon-metrics.core :as anon-metrics]
|
||||
[status-im.utils.universal-links.core :as universal-links]
|
||||
clojure.set
|
||||
status-im.currency.core
|
||||
status-im.navigation
|
||||
status-im.utils.universal-links.core
|
||||
status-im.wallet.custom-tokens.core
|
||||
status-im.waku.core
|
||||
status-im.wallet.choose-recipient.core
|
||||
status-im.wallet.accounts.core
|
||||
status-im.popover.core
|
||||
status-im.visibility-status-popover.core
|
||||
status-im.visibility-status-updates.core
|
||||
status-im.bottom-sheet.core
|
||||
(:require clojure.set
|
||||
[re-frame.core :as re-frame]
|
||||
status-im.add-new.core
|
||||
status-im.search.core
|
||||
status-im.http.core
|
||||
status-im.profile.core
|
||||
[status-im.anon-metrics.core :as anon-metrics]
|
||||
[status-im.async-storage.core :as async-storage]
|
||||
status-im.backup.core
|
||||
status-im.bootnodes.core
|
||||
status-im.bottom-sheet.core
|
||||
status-im.browser.core
|
||||
status-im.browser.permissions
|
||||
[status-im.chat.models :as chat]
|
||||
status-im.chat.models.images
|
||||
status-im.ui.screens.privacy-and-security-settings.events
|
||||
status-im.chat.models.input
|
||||
status-im.chat.models.loading
|
||||
status-im.chat.models.transport
|
||||
[status-im.constants :as constants]
|
||||
status-im.contact.block
|
||||
status-im.contact.chat
|
||||
status-im.contact.core
|
||||
status-im.currency.core
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
status-im.ethereum.subscriptions
|
||||
status-im.fleet.core
|
||||
status-im.http.core
|
||||
[status-im.i18n.i18n :as i18n]
|
||||
status-im.init.core
|
||||
[status-im.keycard.core :as keycard]
|
||||
status-im.log-level.core
|
||||
status-im.mailserver.constants
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.multiaccounts.biometric.core :as biometric]
|
||||
[status-im.multiaccounts.core :as multiaccounts]
|
||||
status-im.multiaccounts.login.core
|
||||
status-im.multiaccounts.logout.core
|
||||
status-im.multiaccounts.update.core
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.navigation :as navigation]
|
||||
status-im.notifications-center.core
|
||||
status-im.pairing.core
|
||||
status-im.popover.core
|
||||
status-im.profile.core
|
||||
status-im.search.core
|
||||
status-im.signals.core
|
||||
status-im.stickers.core
|
||||
status-im.transport.core
|
||||
status-im.init.core
|
||||
status-im.log-level.core
|
||||
status-im.mailserver.constants
|
||||
status-im.ethereum.subscriptions
|
||||
status-im.fleet.core
|
||||
status-im.contact.block
|
||||
status-im.contact.core
|
||||
status-im.contact.chat
|
||||
status-im.chat.models.input
|
||||
status-im.chat.models.loading
|
||||
status-im.bootnodes.core
|
||||
status-im.browser.core
|
||||
status-im.browser.permissions
|
||||
status-im.chat.models.transport
|
||||
status-im.notifications-center.core
|
||||
[status-im.navigation :as navigation]))
|
||||
[status-im.ui.components.permissions :as permissions]
|
||||
[status-im.ui.components.react :as react]
|
||||
status-im.ui.screens.privacy-and-security-settings.events
|
||||
[status-im.utils.dimensions :as dimensions]
|
||||
[status-im.utils.fx :as fx]
|
||||
status-im.utils.logging.core
|
||||
[status-im.utils.universal-links.core :as universal-links]
|
||||
[status-im.utils.utils :as utils]
|
||||
status-im.visibility-status-popover.core
|
||||
status-im.visibility-status-updates.core
|
||||
status-im.waku.core
|
||||
status-im.wallet.accounts.core
|
||||
status-im.wallet.choose-recipient.core
|
||||
[status-im.wallet.core :as wallet]
|
||||
status-im.wallet.custom-tokens.core))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:dismiss-keyboard
|
||||
@ -193,8 +192,24 @@
|
||||
(fx/defn on-will-focus
|
||||
{:events [:screens/on-will-focus]
|
||||
:interceptors [anon-metrics/interceptor]}
|
||||
[cofx view-id]
|
||||
[{:keys [db] :as cofx} view-id]
|
||||
(fx/merge cofx
|
||||
(cond
|
||||
(= :chat view-id)
|
||||
{::async-storage/set! {:chat-id (get-in cofx [:db :current-chat-id])
|
||||
:key-uid (get-in cofx [:db :multiaccount :key-uid])}
|
||||
:db (assoc db :screens/was-focused-once? true)}
|
||||
|
||||
(= :login view-id)
|
||||
{}
|
||||
|
||||
(not (get db :screens/was-focused-once?))
|
||||
{:db (assoc db :screens/was-focused-once? true)}
|
||||
|
||||
:else
|
||||
{::async-storage/set! {:chat-id nil
|
||||
:key-uid nil}
|
||||
:db (assoc db :screens/was-focused-once? true)})
|
||||
#(case view-id
|
||||
:keycard-settings (keycard/settings-screen-did-load %)
|
||||
:reset-card (keycard/reset-card-screen-did-load %)
|
||||
|
@ -325,6 +325,19 @@
|
||||
(logging/set-log-level (:log-level multiaccount))
|
||||
(notifications-center/get-activity-center-notifications-count))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::open-last-chat
|
||||
(fn [key-uid]
|
||||
(async-storage/get-item
|
||||
:chat-id
|
||||
(fn [chat-id]
|
||||
(when chat-id
|
||||
(async-storage/get-item
|
||||
:key-uid
|
||||
(fn [stored-key-uid]
|
||||
(when (= stored-key-uid key-uid)
|
||||
(re-frame/dispatch [:chat.ui/navigate-to-chat chat-id])))))))))
|
||||
|
||||
(fx/defn get-chats-callback
|
||||
{:events [::get-chats-callback]}
|
||||
[{:keys [db] :as cofx}]
|
||||
@ -339,7 +352,8 @@
|
||||
::initialize-wallet
|
||||
(fn [accounts custom-tokens favourites]
|
||||
(re-frame/dispatch [::initialize-wallet
|
||||
accounts custom-tokens favourites]))}
|
||||
accounts custom-tokens favourites]))
|
||||
::open-last-chat (get-in db [:multiaccount :key-uid])}
|
||||
notifications-enabled?
|
||||
(assoc ::notifications/enable nil))
|
||||
(transport/start-messenger)
|
||||
@ -381,7 +395,7 @@
|
||||
config/metrics-enabled?)
|
||||
(navigation/navigate-to :anon-metrics-opt-in {})
|
||||
|
||||
:else (re-frame/dispatch [:init-root :chat-stack]))))
|
||||
:else (re-frame/dispatch [:init-root :chat-stack]))))
|
||||
|
||||
(fx/defn login-only-events
|
||||
[{:keys [db] :as cofx} key-uid password save-password?]
|
||||
|
@ -1,6 +1,6 @@
|
||||
(ns status-im.navigation
|
||||
(:require [status-im.utils.fx :as fx]
|
||||
[status-im.anon-metrics.core :as anon-metrics]))
|
||||
(:require [status-im.anon-metrics.core :as anon-metrics]
|
||||
[status-im.utils.fx :as fx]))
|
||||
|
||||
(defn- all-screens-params [db view screen-params]
|
||||
(cond-> db
|
||||
|
@ -1,17 +1,18 @@
|
||||
(ns status-im.navigation.core
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ui.screens.views :as views]
|
||||
[status-im.utils.platform :as platform]
|
||||
[status-im.navigation.roots :as roots]
|
||||
[status-im.ui.components.react :as react]
|
||||
[quo.components.text-input :as quo.text-input]
|
||||
[status-im.ui.components.icons.icons :as icons]
|
||||
[quo.design-system.colors :as quo.colors]
|
||||
[status-im.utils.fx :as fx]
|
||||
["react-native-navigation" :refer (Navigation)]
|
||||
["react-native" :as rn]
|
||||
["react-native-gesture-handler" :refer (gestureHandlerRootHOC)]
|
||||
["react-native" :as rn]))
|
||||
["react-native-navigation" :refer (Navigation)]
|
||||
[quo.components.text-input :as quo.text-input]
|
||||
[quo.design-system.colors :as quo.colors]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.navigation.roots :as roots]
|
||||
[status-im.ui.components.icons.icons :as icons]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.views :as views]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.platform :as platform]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def debug? ^boolean js/goog.DEBUG)
|
||||
|
||||
@ -26,6 +27,7 @@
|
||||
|
||||
;; REGISTER COMPONENT (LAZY)
|
||||
(defn reg-comp [key]
|
||||
(log/debug "reg-comp" key)
|
||||
(if-let [comp (get views/components (keyword key))]
|
||||
(.registerComponent Navigation key (fn [] (views/component comp)))
|
||||
(let [screen (views/screen key)]
|
||||
@ -35,6 +37,7 @@
|
||||
(.setLazyComponentRegistrator Navigation reg-comp))
|
||||
|
||||
(defn dismiss-all-modals []
|
||||
(log/debug "dissmiss-all-modals")
|
||||
(when @curr-modal
|
||||
(reset! curr-modal false)
|
||||
(reset! dissmissing true)
|
||||
@ -44,6 +47,7 @@
|
||||
|
||||
;; PUSH SCREEN
|
||||
(defn navigate [comp]
|
||||
(log/debug "NAVIGATE" comp)
|
||||
(let [{:keys [options]} (get views/screens comp)]
|
||||
(.push Navigation
|
||||
(name @root-comp-id)
|
||||
@ -57,6 +61,7 @@
|
||||
|
||||
;; OPEN MODAL
|
||||
(defn update-modal-topbar-options [options]
|
||||
(log/debug "update-modal-topbar-options" options)
|
||||
(merge options
|
||||
(roots/merge-top-bar {:elevation 0
|
||||
:noBorder true
|
||||
@ -68,6 +73,7 @@
|
||||
options)))
|
||||
|
||||
(defn open-modal [comp]
|
||||
(log/debug "open-modal" comp)
|
||||
(let [{:keys [options]} (get views/screens comp)]
|
||||
(if @dissmissing
|
||||
(reset! dissmissing comp)
|
||||
@ -88,6 +94,7 @@
|
||||
|
||||
;; DISSMISS MODAL
|
||||
(defn dissmissModal []
|
||||
(log/debug "dissmissModal")
|
||||
(reset! dissmissing true)
|
||||
(.dismissModal Navigation (name (last @modals))))
|
||||
|
||||
@ -105,6 +112,7 @@
|
||||
(handler)))))))
|
||||
|
||||
(defn set-view-id [view-id]
|
||||
(log/debug "set-view-id" view-id)
|
||||
(when-let [{:keys [on-focus]} (get views/screens view-id)]
|
||||
(re-frame/dispatch [:set :view-id view-id])
|
||||
(re-frame/dispatch [:screens/on-will-focus view-id])
|
||||
@ -135,6 +143,7 @@
|
||||
(.events Navigation)
|
||||
(fn [^js evn]
|
||||
(let [view-id (keyword (.-componentName evn))]
|
||||
(log/debug "screen-appear-reg" view-id)
|
||||
(when (get views/screens view-id)
|
||||
(when (and (not= view-id :bottom-sheet)
|
||||
(not= view-id :popover)
|
||||
@ -159,6 +168,7 @@
|
||||
(re-frame/reg-fx
|
||||
:init-root-fx
|
||||
(fn [new-root-id]
|
||||
(log/debug :init-root-fx new-root-id)
|
||||
(reset! root-comp-id new-root-id)
|
||||
(reset! root-id @root-comp-id)
|
||||
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
|
||||
@ -166,6 +176,7 @@
|
||||
(re-frame/reg-fx
|
||||
:init-root-with-component-fx
|
||||
(fn [[new-root-id new-root-comp-id]]
|
||||
(log/debug :init-root-with-component-fx new-root-id new-root-comp-id)
|
||||
(reset! root-comp-id new-root-comp-id)
|
||||
(reset! root-id @root-comp-id)
|
||||
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
|
||||
@ -173,6 +184,7 @@
|
||||
(fx/defn set-multiaccount-root
|
||||
{:events [::set-multiaccount-root]}
|
||||
[{:keys [db]}]
|
||||
(log/debug :set-multiaccounts-root)
|
||||
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
|
||||
keycard-account? (boolean (get-in db [:multiaccounts/multiaccounts
|
||||
key-uid
|
||||
@ -192,6 +204,7 @@
|
||||
(.hide ^js splash-screen))))
|
||||
|
||||
(defn get-screen-component [comp]
|
||||
(log/debug :get-screen-component comp)
|
||||
(let [{:keys [options]} (get views/screens comp)]
|
||||
{:component {:id comp
|
||||
:name comp
|
||||
@ -203,6 +216,7 @@
|
||||
(re-frame/reg-fx
|
||||
:set-stack-root-fx
|
||||
(fn [[stack comp]]
|
||||
(log/debug :set-stack-root-fx stack comp)
|
||||
(.setStackRoot Navigation
|
||||
(name stack)
|
||||
(clj->js (if (vector? comp)
|
||||
@ -225,6 +239,7 @@
|
||||
(re-frame/reg-fx
|
||||
:change-tab-fx
|
||||
(fn [tab]
|
||||
(log/debug :change-tab-fx)
|
||||
(reset! root-comp-id (get tab-root-ids (get tab-key-idx tab)))
|
||||
(.mergeOptions Navigation "tabs-stack" (clj->js {:bottomTabs {:currentTabIndex (get tab-key-idx tab)}}))
|
||||
;;when we change tab we want to dismiss all modals
|
||||
@ -234,6 +249,7 @@
|
||||
(re-frame/reg-fx
|
||||
:change-tab-count-fx
|
||||
(fn [[tab cnt]]
|
||||
(log/debug :change-tab-count-fx tab cnt)
|
||||
(.mergeOptions Navigation
|
||||
(name (get tab-root-ids (get tab-key-idx tab)))
|
||||
(clj->js {:bottomTab (cond
|
||||
@ -253,6 +269,7 @@
|
||||
(re-frame/reg-fx
|
||||
:pop-to-root-tab-fx
|
||||
(fn [comp]
|
||||
(log/debug :pop-to-root-tab-fx comp)
|
||||
(dismiss-all-modals)
|
||||
(.popToRoot Navigation (name comp))))
|
||||
|
||||
@ -343,11 +360,13 @@
|
||||
(re-frame/reg-fx
|
||||
:navigate-to-fx
|
||||
(fn [key]
|
||||
(log/debug :navigate-to-fx key)
|
||||
(navigate key)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:navigate-back-fx
|
||||
(fn []
|
||||
(log/debug :navigate-back-fx)
|
||||
(if @curr-modal
|
||||
(dissmissModal)
|
||||
(.pop Navigation (name @root-comp-id)))))
|
||||
@ -355,5 +374,6 @@
|
||||
(re-frame/reg-fx
|
||||
:navigate-replace-fx
|
||||
(fn [view-id]
|
||||
(log/debug :navigate-replace-fx view-id)
|
||||
(.pop Navigation (name @root-comp-id))
|
||||
(navigate view-id)))
|
||||
|
@ -1,5 +1,6 @@
|
||||
(ns status-im.notifications.local
|
||||
(:require [status-im.utils.fx :as fx]
|
||||
(:require [status-im.async-storage.core :as async-storage]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.ethereum.decode :as decode]
|
||||
["@react-native-community/push-notification-ios" :default pn-ios]
|
||||
[status-im.notifications.android :as pn-android]
|
||||
@ -40,6 +41,7 @@
|
||||
|
||||
(defn handle-notification-press [{{deep-link :deepLink} :userInfo
|
||||
interaction :userInteraction}]
|
||||
(async-storage/set-item! (str :chat-id) nil)
|
||||
(when (and deep-link
|
||||
(or platform/ios?
|
||||
(and platform/android? interaction)))
|
||||
|
@ -51,11 +51,14 @@
|
||||
(swap! handlers/handler-nesting-level inc))
|
||||
(let [[first-arg & rest-args] args
|
||||
initial-fxs? (map? first-arg)
|
||||
fx-fns (if initial-fxs? rest-args args)]
|
||||
(clojure.core/reduce (fn [fxs fx-fn]
|
||||
(let [updated-cofx (update-db cofx fxs)]
|
||||
(if fx-fn
|
||||
(safe-merge fxs (fx-fn updated-cofx))
|
||||
fxs)))
|
||||
(if initial-fxs? first-arg {:db db})
|
||||
fx-fns)))
|
||||
fx-fns (if initial-fxs? rest-args args)
|
||||
res
|
||||
(clojure.core/reduce (fn [fxs fx-fn]
|
||||
(let [updated-cofx (update-db cofx fxs)]
|
||||
(if fx-fn
|
||||
(safe-merge fxs (fx-fn updated-cofx))
|
||||
fxs)))
|
||||
(if initial-fxs? first-arg {:db db})
|
||||
fx-fns)]
|
||||
(swap! handlers/handler-nesting-level dec)
|
||||
res))
|
||||
|
Loading…
x
Reference in New Issue
Block a user