From a895bde6612e7a2b22a84b6ca7c583bafc9ebc9e Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 7 Oct 2022 17:18:15 +0200 Subject: [PATCH] fix: make sure subscriptions are properly inherited between lists and namespaces --- .../namespace/namespace-settings-dropdown.vue | 20 +++++++++++++++---- src/stores/namespaces.ts | 11 ++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/components/namespace/namespace-settings-dropdown.vue b/src/components/namespace/namespace-settings-dropdown.vue index 778616215..fb71ba66a 100644 --- a/src/components/namespace/namespace-settings-dropdown.vue +++ b/src/components/namespace/namespace-settings-dropdown.vue @@ -33,14 +33,13 @@ > {{ $t('menu.archive') }} - (null) onMounted(() => { subscription.value = props.namespace.subscription }) + +function setSubscriptionInStore(sub: ISubscription) { + subscription.value = sub + namespaceStore.setNamespaces([ + { + ...props.namespace, + subscription: sub, + }, + ]) +} diff --git a/src/stores/namespaces.ts b/src/stores/namespaces.ts index 86a7f0268..5d83948ba 100644 --- a/src/stores/namespaces.ts +++ b/src/stores/namespaces.ts @@ -43,7 +43,7 @@ export const useNamespaceStore = defineStore('namespace', { getNamespaceById: state => (namespaceId: INamespace['id']) => { return state.namespaces.find(({id}) => id == namespaceId) || null }, - + searchNamespace() { return (query: string) => ( search(query) @@ -64,6 +64,13 @@ export const useNamespaceStore = defineStore('namespace', { this.namespaces = namespaces namespaces.forEach(n => { add(n) + + // Check for each list in that namespace if it has a subscription and set it if not + n.lists.forEach(l => { + if (l.subscription === null || l.subscription.entity !== 'list') { + l.subscription = n.subscription + } + }) }) }, @@ -203,5 +210,5 @@ export const useNamespaceStore = defineStore('namespace', { // support hot reloading if (import.meta.hot) { - import.meta.hot.accept(acceptHMRUpdate(useNamespaceStore, import.meta.hot)) + import.meta.hot.accept(acceptHMRUpdate(useNamespaceStore, import.meta.hot)) } \ No newline at end of file