From 45bf2ac867edd115d0271b65638cfe7c83c773c6 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 2 May 2024 15:08:17 -0500 Subject: [PATCH] useCurrentUserStore() has been renamed to useCurrentUser() --- .../{currentUserStore.mjs => useCurrentUser.mjs} | 14 +++++++++++++- composables/ving/useMessageBus.mjs | 2 +- composables/ving/userSettingsButtons.mjs | 2 +- composables/ving/userSettingsLinks.mjs | 2 +- layouts/default.vue | 2 +- middleware/admin.mjs | 2 +- middleware/auth.mjs | 2 +- pages/user/[id]/profile.vue | 2 +- pages/user/admin/[id].vue | 2 +- pages/user/create.vue | 2 +- pages/user/login.vue | 2 +- pages/user/logout.vue | 2 +- pages/user/must-verify-email.vue | 2 +- pages/user/settings/account.vue | 2 +- pages/user/settings/apikeys.vue | 2 +- pages/user/settings/index.vue | 2 +- pages/user/settings/preferences.vue | 2 +- pages/user/verify-email.vue | 2 +- ving/docs/change-log.md | 1 + ving/docs/subsystems/ui.md | 4 ++-- 20 files changed, 33 insertions(+), 20 deletions(-) rename composables/ving/{currentUserStore.mjs => useCurrentUser.mjs} (88%) diff --git a/composables/ving/currentUserStore.mjs b/composables/ving/useCurrentUser.mjs similarity index 88% rename from composables/ving/currentUserStore.mjs rename to composables/ving/useCurrentUser.mjs index d990bca7..9f3e0306 100644 --- a/composables/ving/currentUserStore.mjs +++ b/composables/ving/useCurrentUser.mjs @@ -4,7 +4,7 @@ import { isObject, isUndefined } from '#ving/utils/identify.mjs'; const query = { includeOptions: true, includeMeta: true, includeLinks: true }; -export const useCurrentUserStore = defineStore('currentUser', { +export const useCurrentUser = defineStore('currentUser', { state: () => ({ props: {}, meta: {}, @@ -71,6 +71,18 @@ export const useCurrentUserStore = defineStore('currentUser', { this.setState(response.data); return response; }, + async save(key) { + const valuesToSave = {}; + valuesToSave[key] = this.props[key]; + const response = await useRest(this.links?.self?.href, { + method: 'put', + body: valuesToSave, + query, + }); + if (response.data) + this.setState(response.data); + return response; + }, async create(newUser) { const response = await useRest(`/api/${useRestVersion()}/user`, { method: 'post', diff --git a/composables/ving/useMessageBus.mjs b/composables/ving/useMessageBus.mjs index 7addff9b..c42ba125 100644 --- a/composables/ving/useMessageBus.mjs +++ b/composables/ving/useMessageBus.mjs @@ -11,7 +11,7 @@ */ export default async function useMessageBus() { const notify = useNotifyStore(); - const currentUser = useCurrentUserStore(); + const currentUser = useCurrentUser(); let reconnectFrequencySeconds = 1; let bus = null; diff --git a/composables/ving/userSettingsButtons.mjs b/composables/ving/userSettingsButtons.mjs index 922645f3..33c92b7d 100644 --- a/composables/ving/userSettingsButtons.mjs +++ b/composables/ving/userSettingsButtons.mjs @@ -6,7 +6,7 @@ */ export default () => { - const currentUser = useCurrentUserStore(); + const currentUser = useCurrentUser(); const buttons = computed(() => { const out = [ { label: 'Sign Out', to: '/user/logout', icon: 'ph:door', severity: 'primary' }, diff --git a/composables/ving/userSettingsLinks.mjs b/composables/ving/userSettingsLinks.mjs index 80cca285..b4f47e53 100644 --- a/composables/ving/userSettingsLinks.mjs +++ b/composables/ving/userSettingsLinks.mjs @@ -6,7 +6,7 @@ */ export default () => { - const currentUser = useCurrentUserStore(); + const currentUser = useCurrentUser(); const links = computed(() => { const out = [ { label: 'Profile', to: '/user/settings', icon: 'ph:user' }, diff --git a/layouts/default.vue b/layouts/default.vue index c25e5b6d..9f65b1f5 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -64,7 +64,7 @@ \ No newline at end of file diff --git a/pages/user/admin/[id].vue b/pages/user/admin/[id].vue index f18b913e..372e65c9 100644 --- a/pages/user/admin/[id].vue +++ b/pages/user/admin/[id].vue @@ -120,7 +120,7 @@ onBeforeRouteLeave(() => user.dispose()); async function become() { await user.call('post', user.links?.self.href + '/become', undefined, { async onSuccess() { - const currentUser = useCurrentUserStore(); + const currentUser = useCurrentUser(); currentUser.fetch(); await navigateTo('/'); } diff --git a/pages/user/create.vue b/pages/user/create.vue index fc7d44bc..66c169a0 100644 --- a/pages/user/create.vue +++ b/pages/user/create.vue @@ -58,7 +58,7 @@ \ No newline at end of file diff --git a/pages/user/settings/preferences.vue b/pages/user/settings/preferences.vue index 71c40d22..c5dbaa08 100644 --- a/pages/user/settings/preferences.vue +++ b/pages/user/settings/preferences.vue @@ -19,7 +19,7 @@ definePageMeta({ middleware: ['auth'] }); -const currentUser = useCurrentUserStore(); +const currentUser = useCurrentUser(); const links = userSettingsLinks(); const buttons = userSettingsButtons(); \ No newline at end of file diff --git a/pages/user/verify-email.vue b/pages/user/verify-email.vue index 54a2eafa..a0aed39d 100644 --- a/pages/user/verify-email.vue +++ b/pages/user/verify-email.vue @@ -12,7 +12,7 @@