fix: make sure subscriptions are properly inherited between lists and namespaces
This commit is contained in:
parent
4ebe17f4f3
commit
a895bde661
2 changed files with 25 additions and 6 deletions
|
@ -33,14 +33,13 @@
|
|||
>
|
||||
{{ $t('menu.archive') }}
|
||||
</dropdown-item>
|
||||
<task-subscription
|
||||
v-if="subscription"
|
||||
<Subscription
|
||||
class="has-no-shadow"
|
||||
:is-button="false"
|
||||
entity="namespace"
|
||||
:entity-id="namespace.id"
|
||||
:model-value="subscription"
|
||||
@update:model-value="sub => subscription = sub"
|
||||
@update:model-value="setSubscriptionInStore"
|
||||
type="dropdown"
|
||||
/>
|
||||
<dropdown-item
|
||||
|
@ -59,9 +58,10 @@ import {ref, onMounted, type PropType} from 'vue'
|
|||
|
||||
import Dropdown from '@/components/misc/dropdown.vue'
|
||||
import DropdownItem from '@/components/misc/dropdown-item.vue'
|
||||
import TaskSubscription from '@/components/misc/subscription.vue'
|
||||
import Subscription from '@/components/misc/subscription.vue'
|
||||
import type {INamespace} from '@/modelTypes/INamespace'
|
||||
import type {ISubscription} from '@/modelTypes/ISubscription'
|
||||
import {useNamespaceStore} from '@/stores/namespaces'
|
||||
|
||||
const props = defineProps({
|
||||
namespace: {
|
||||
|
@ -70,8 +70,20 @@ const props = defineProps({
|
|||
},
|
||||
})
|
||||
|
||||
const namespaceStore = useNamespaceStore()
|
||||
|
||||
const subscription = ref<ISubscription | null>(null)
|
||||
onMounted(() => {
|
||||
subscription.value = props.namespace.subscription
|
||||
})
|
||||
|
||||
function setSubscriptionInStore(sub: ISubscription) {
|
||||
subscription.value = sub
|
||||
namespaceStore.setNamespaces([
|
||||
{
|
||||
...props.namespace,
|
||||
subscription: sub,
|
||||
},
|
||||
])
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -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))
|
||||
}
|
Loading…
Reference in a new issue