From d9396e3f08a0807f06720f6114e94a3141288fbe Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 8 Apr 2024 16:43:26 -0400 Subject: [PATCH] Why is this needed? --- client/src/components/PageDisplay/PageDisplay.vue | 6 +++--- client/src/stores/userStore.ts | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/components/PageDisplay/PageDisplay.vue b/client/src/components/PageDisplay/PageDisplay.vue index d3fb11855692..46839be4e4bd 100644 --- a/client/src/components/PageDisplay/PageDisplay.vue +++ b/client/src/components/PageDisplay/PageDisplay.vue @@ -46,8 +46,8 @@ export default { setup() { const { config, isConfigLoaded } = useConfig(true); const userStore = useUserStore(); - const { currentUser } = storeToRefs(userStore); - return { config, currentUser, isConfigLoaded }; + const { currentUser, isCurrentUserLoaded } = storeToRefs(userStore); + return { config, currentUser, isConfigLoaded, isCurrentUserLoaded }; }, data() { return { @@ -56,7 +56,7 @@ export default { }, computed: { userOwnsPage() { - return this.currentUser.username === this.page.username; + return this.isCurrentUserLoaded && this.currentUser.username === this.page.username; }, dataUrl() { return `/api/pages/${this.pageId}`; diff --git a/client/src/stores/userStore.ts b/client/src/stores/userStore.ts index 55a49d491209..0a5e124354b1 100644 --- a/client/src/stores/userStore.ts +++ b/client/src/stores/userStore.ts @@ -25,6 +25,7 @@ type ListViewMode = "grid" | "list"; export const useUserStore = defineStore("userStore", () => { const currentUser = ref(null); + const isCurrentUserLoaded = computed(() => !!currentUser.value); const currentPreferences = ref(null); // explicitly pass current User, because userStore might not exist yet @@ -151,6 +152,7 @@ export const useUserStore = defineStore("userStore", () => { currentPreferences, isAdmin, isAnonymous, + isCurrentUserLoaded, currentTheme, currentFavorites, toggledSideBar,