From 464a686c04139d4667416fe5c999f83952330b92 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 13 Apr 2021 09:46:36 +0200 Subject: [PATCH] :bug: Fix incorrect handling of user lang selection. That causes double loading of the http resources in some circumstances. --- frontend/src/app/main.cljs | 14 +++++++------- frontend/src/app/main/ui/viewer.cljs | 16 ++++++++-------- frontend/src/app/util/i18n.cljs | 1 + 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/main.cljs b/frontend/src/app/main.cljs index 2126bead20..3df6cd88d3 100644 --- a/frontend/src/app/main.cljs +++ b/frontend/src/app/main.cljs @@ -79,20 +79,20 @@ (defn init-ui [] - (st/emit! (rt/initialize-router ui/routes) - (rt/initialize-history on-navigate)) - - (st/emit! (udu/fetch-profile) - (udu/fetch-user-teams)) (mf/mount (mf/element ui/app) (dom/get-element "app")) - (mf/mount (mf/element modal) (dom/get-element "modal"))) + (mf/mount (mf/element modal) (dom/get-element "modal"))) (defn ^:export init [] (i18n/init! cfg/translations) (theme/init! cfg/themes) (st/init) - (init-ui)) + (init-ui) + + (st/emit! (rt/initialize-router ui/routes) + (rt/initialize-history on-navigate) + (udu/fetch-profile) + (udu/fetch-user-teams))) (defn reinit [] diff --git a/frontend/src/app/main/ui/viewer.cljs b/frontend/src/app/main/ui/viewer.cljs index 89fdbc91cb..0c651fb495 100644 --- a/frontend/src/app/main/ui/viewer.cljs +++ b/frontend/src/app/main/ui/viewer.cljs @@ -265,19 +265,19 @@ (mf/defc viewer-page [{:keys [file-id page-id index token section] :as props}] - - (mf/use-effect - (mf/deps file-id page-id token) - (st/emitf (dv/initialize props))) - (let [data (mf/deref refs/viewer-data) state (mf/deref refs/viewer-local)] + (mf/use-effect + (mf/deps file-id page-id token) + (fn [] + (prn "viewer-page$use-effect") + (st/emit! (dv/initialize props)))) + (mf/use-effect (mf/deps (:file data)) - #(when (:file data) - (dom/set-html-title (tr "title.viewer" - (get-in data [:file :name]))))) + #(when-let [name (get-in data [:file :name])] + (dom/set-html-title (tr "title.viewer" name)))) (when (and data state) [:& viewer-content diff --git a/frontend/src/app/util/i18n.cljs b/frontend/src/app/util/i18n.cljs index 15d00312fe..20a70ad474 100644 --- a/frontend/src/app/util/i18n.cljs +++ b/frontend/src/app/util/i18n.cljs @@ -73,6 +73,7 @@ (swap! storage assoc ::locale lang) (reset! locale lang)) (do + (swap! storage dissoc ::locale) (reset! locale (autodetect))))) (defn reset-locale