Use a pinia store to manage session state
Replace the convoluted useAccountSession composable with a pinia store that in addition allows for the consolidation of all session related functions to grouped into one module.
This commit is contained in:
parent
c47452a8b4
commit
fae8b4e2e4
21 changed files with 181 additions and 118 deletions
|
@ -18,15 +18,15 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { data: session, refresh: refreshSession } = await useAccountSession();
|
||||
const sessionStore = useSessionStore();
|
||||
const { supported, subscription, getSubscription, subscribe, unsubscribe } = usePushNotification();
|
||||
const subscribed = computed(() => Boolean(subscription.value && session.value?.push))
|
||||
const subscribed = computed(() => Boolean(subscription.value && sessionStore.push));
|
||||
async function onClick() {
|
||||
if (!subscribed.value)
|
||||
await subscribe();
|
||||
else
|
||||
await unsubscribe();
|
||||
await refreshSession();
|
||||
await sessionStore.fetch();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue