From b4b20e4260c6f6b2caca96ebb44b603b4f304d65 Mon Sep 17 00:00:00 2001 From: Michael Dausmann Date: Fri, 7 Apr 2023 23:28:13 +1000 Subject: [PATCH] force user initialisation - fixes #2 --- lib/services/util.service.ts | 2 +- pages/account.vue | 4 ++++ pages/dashboard.vue | 4 ++++ pages/pricing.vue | 3 +++ server/trpc/context.ts | 4 ++-- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/services/util.service.ts b/lib/services/util.service.ts index 8ec4cb3..fe60c05 100644 --- a/lib/services/util.service.ts +++ b/lib/services/util.service.ts @@ -13,7 +13,7 @@ export class UtilService { return String(error) } - public static circleSafeStringify(obj: any) { + public static stringifySafely(obj: any) { let cache: any[] = []; let str = JSON.stringify(obj, function(key, value) { if (typeof value === "object" && value !== null) { diff --git a/pages/account.vue b/pages/account.vue index 4526838..1e92881 100644 --- a/pages/account.vue +++ b/pages/account.vue @@ -10,6 +10,10 @@ const config = useRuntimeConfig(); const newAccountName = ref(""); + onMounted(async () => { + await authStore.initUser(); + }); + watchEffect(async () => { if (activeMembership.value) { await accountStore.getActiveAccountMembers(); diff --git a/pages/dashboard.vue b/pages/dashboard.vue index 3a9bbce..d60a51b 100644 --- a/pages/dashboard.vue +++ b/pages/dashboard.vue @@ -11,6 +11,10 @@ const notesStore = useNotesStore(); const { notes } = storeToRefs(notesStore); // ensure the notes list is reactive + onMounted(async () => { + await authStore.initUser(); + }); + watchEffect(async () => { if (activeMembership.value) { await notesStore.fetchNotesForCurrentUser(); diff --git a/pages/pricing.vue b/pages/pricing.vue index 70f209c..17e5ae0 100644 --- a/pages/pricing.vue +++ b/pages/pricing.vue @@ -5,6 +5,9 @@ const authStore = useAuthStore() const { activeMembership } = storeToRefs(authStore); + onMounted(async () => { + await authStore.initUser(); + });