From b9ccb4e52c6003cf5f12ed3cf9bb909eeac8c295 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 25 Nov 2021 09:53:09 +0100 Subject: [PATCH] :bug: Fix issues on login being logged. --- frontend/src/app/main/data/dashboard.cljs | 15 ++++++++------- frontend/src/app/main/data/users.cljs | 9 +++++++-- frontend/src/app/main/ui/dashboard.cljs | 3 ++- frontend/src/app/main/ui/dashboard/file_menu.cljs | 2 +- frontend/src/app/main/ui/dashboard/grid.cljs | 5 +++-- frontend/src/app/main/ui/dashboard/projects.cljs | 15 ++++++++------- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index 982e268f3..82ec0cb6a 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -237,13 +237,14 @@ (update :dashboard-files d/merge files)))))) (defn fetch-recent-files - [] - (ptk/reify ::fetch-recent-files - ptk/WatchEvent - (watch [_ state _] - (let [team-id (:current-team-id state)] - (->> (rp/query :team-recent-files {:team-id team-id}) - (rx/map recent-files-fetched)))))) + ([] (fetch-recent-files nil)) + ([team-id] + (ptk/reify ::fetch-recent-files + ptk/WatchEvent + (watch [_ state _] + (let [team-id (or team-id (:current-team-id state))] + (->> (rp/query :team-recent-files {:team-id team-id}) + (rx/map recent-files-fetched))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data Selection diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 17ef70422..d5e64f95b 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -154,7 +154,7 @@ ptk/WatchEvent (watch [_ _ _] - (let [team-id (get-current-team-id profile)] + (let [team-id (:default-team-id profile)] (->> (rx/concat (rx/of (profile-fetched profile) (fetch-teams)) @@ -184,7 +184,12 @@ (rx/map (fn [profile] (with-meta profile {::ev/source "login"}))) - (rx/map logged-in)))))) + (rx/map logged-in) + (rx/observe-on :async)))) + + ptk/EffectEvent + (effect [_ _ _] + (reset! storage {})))) (defn login-from-token [{:keys [profile] :as tdata}] diff --git a/frontend/src/app/main/ui/dashboard.cljs b/frontend/src/app/main/ui/dashboard.cljs index bd0d383e4..40f9df49c 100644 --- a/frontend/src/app/main/ui/dashboard.cljs +++ b/frontend/src/app/main/ui/dashboard.cljs @@ -91,7 +91,8 @@ (mf/use-effect (mf/deps team-id) - (st/emitf (dd/initialize {:id team-id}))) + (fn [] + (st/emit! (dd/initialize {:id team-id})))) [:& (mf/provider ctx/current-team-id) {:value team-id} [:& (mf/provider ctx/current-project-id) {:value project-id} diff --git a/frontend/src/app/main/ui/dashboard/file_menu.cljs b/frontend/src/app/main/ui/dashboard/file_menu.cljs index 531df875e..4ac841f2f 100644 --- a/frontend/src/app/main/ui/dashboard/file_menu.cljs +++ b/frontend/src/app/main/ui/dashboard/file_menu.cljs @@ -115,7 +115,7 @@ (st/emit! (dm/success (tr "dashboard.success-move-file")))) (if (or navigate? (not= team-id current-team-id)) (st/emit! (dd/go-to-files team-id project-id)) - (st/emit! (dd/fetch-recent-files) + (st/emit! (dd/fetch-recent-files team-id) (dd/clear-selected-files)))) on-move diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index f91e1de5c..dc181f6e4 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -327,8 +327,9 @@ on-finish-import (mf/use-callback + (mf/deps (:id team)) (fn [] - (st/emit! (dd/fetch-recent-files) + (st/emit! (dd/fetch-recent-files (:id team)) (dd/clear-selected-files)))) import-files (use-import-file project-id on-finish-import) @@ -366,7 +367,7 @@ on-drop-success (fn [] (st/emit! (dm/success (tr "dashboard.success-move-file")) - (dd/fetch-recent-files) + (dd/fetch-recent-files (:id team)) (dd/clear-selected-files))) on-drop diff --git a/frontend/src/app/main/ui/dashboard/projects.cljs b/frontend/src/app/main/ui/dashboard/projects.cljs index 76da2bc5e..d25620b04 100644 --- a/frontend/src/app/main/ui/dashboard/projects.cljs +++ b/frontend/src/app/main/ui/dashboard/projects.cljs @@ -97,9 +97,10 @@ on-import (mf/use-callback + (mf/deps (:id project) (:id team)) (fn [] (st/emit! (dd/fetch-files {:project-id (:id project)}) - (dd/fetch-recent-files) + (dd/fetch-recent-files (:id team)) (dd/clear-selected-files))))] [:div.dashboard-project-row {:class (when first? "first")} @@ -163,15 +164,15 @@ (mf/use-effect (mf/deps team) (fn [] - (when team - (let [tname (if (:is-default team) - (tr "dashboard.your-penpot") - (:name team))] - (dom/set-html-title (tr "title.dashboard.projects" tname)))))) + (let [tname (if (:is-default team) + (tr "dashboard.your-penpot") + (:name team))] + (dom/set-html-title (tr "title.dashboard.projects" tname))))) (mf/use-effect + (mf/deps (:id team)) (fn [] - (st/emit! (dd/fetch-recent-files) + (st/emit! (dd/fetch-recent-files (:id team)) (dd/clear-selected-files)))) (when (seq projects)