From 7dd9df98b2dcc420f0b797cfdbb0c1266d61278f Mon Sep 17 00:00:00 2001 From: Daniel Regeci Date: Sun, 6 May 2018 20:47:17 +0700 Subject: [PATCH] [FIX #3603] Tabs are visible along with keyboard when focusing on input field (android) Signed-off-by: Julien Eluard --- src/status_im/ui/screens/navigation.cljs | 21 +++++++++++++++---- .../ui/screens/profile/navigation.cljs | 4 ++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/status_im/ui/screens/navigation.cljs b/src/status_im/ui/screens/navigation.cljs index f98daafdd7..030f6781c5 100644 --- a/src/status_im/ui/screens/navigation.cljs +++ b/src/status_im/ui/screens/navigation.cljs @@ -35,6 +35,11 @@ (defn navigate-forget [view-id {:keys [db]}] {:db (assoc db :view-id view-id)}) +(defmulti unload-data! + (fn [db] (:view-id db))) + +(defmethod unload-data! :default [db] db) + (defmulti preload-data! (fn [db [_ view-id]] (or view-id (:view-id db)))) @@ -57,23 +62,31 @@ db (push-view db go-to-view-id))))) +(def unload-data-interceptor + (re-frame/->interceptor + :id unload-data-interceptor + :before (fn unload-data-interceptor-before + [context] + (let [db (re-frame/get-coeffect context :db)] + (re-frame/assoc-coeffect context :db (unload-data! db)))))) + ;; event handlers (handlers/register-handler-db :navigate-to - (re-frame/enrich preload-data!) + [unload-data-interceptor (re-frame/enrich preload-data!)] (fn [db [_ & params]] (apply navigate-to db params))) (handlers/register-handler-db :navigate-to-modal - (re-frame/enrich preload-data!) + [unload-data-interceptor (re-frame/enrich preload-data!)] (fn [db [_ modal-view]] (assoc db :modal modal-view))) (handlers/register-handler-fx :navigation-replace - (re-frame/enrich preload-data!) + [unload-data-interceptor (re-frame/enrich preload-data!)] (fn [cofx [_ view-id]] (replace-view view-id cofx))) @@ -102,7 +115,7 @@ (handlers/register-handler-fx :navigate-to-tab - (re-frame/enrich preload-data!) + [unload-data-interceptor (re-frame/enrich preload-data!)] (fn [{:keys [db] :as cofx} [_ view-id]] (handlers-macro/merge-fx cofx {:db (-> db diff --git a/src/status_im/ui/screens/profile/navigation.cljs b/src/status_im/ui/screens/profile/navigation.cljs index 7d925b15a2..710fae988c 100644 --- a/src/status_im/ui/screens/profile/navigation.cljs +++ b/src/status_im/ui/screens/profile/navigation.cljs @@ -12,3 +12,7 @@ (defmethod navigation/preload-data! :backup-seed [db] (assoc db :my-profile/seed {:step :intro})) + +(defmethod navigation/unload-data! :my-profile + [db] + (dissoc db :my-profile/editing?))