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,