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') }}
|
{{ $t('menu.archive') }}
|
||||||
</dropdown-item>
|
</dropdown-item>
|
||||||
<task-subscription
|
<Subscription
|
||||||
v-if="subscription"
|
|
||||||
class="has-no-shadow"
|
class="has-no-shadow"
|
||||||
:is-button="false"
|
:is-button="false"
|
||||||
entity="namespace"
|
entity="namespace"
|
||||||
:entity-id="namespace.id"
|
:entity-id="namespace.id"
|
||||||
:model-value="subscription"
|
:model-value="subscription"
|
||||||
@update:model-value="sub => subscription = sub"
|
@update:model-value="setSubscriptionInStore"
|
||||||
type="dropdown"
|
type="dropdown"
|
||||||
/>
|
/>
|
||||||
<dropdown-item
|
<dropdown-item
|
||||||
|
@ -59,9 +58,10 @@ import {ref, onMounted, type PropType} from 'vue'
|
||||||
|
|
||||||
import Dropdown from '@/components/misc/dropdown.vue'
|
import Dropdown from '@/components/misc/dropdown.vue'
|
||||||
import DropdownItem from '@/components/misc/dropdown-item.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 {INamespace} from '@/modelTypes/INamespace'
|
||||||
import type {ISubscription} from '@/modelTypes/ISubscription'
|
import type {ISubscription} from '@/modelTypes/ISubscription'
|
||||||
|
import {useNamespaceStore} from '@/stores/namespaces'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
namespace: {
|
namespace: {
|
||||||
|
@ -70,8 +70,20 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const namespaceStore = useNamespaceStore()
|
||||||
|
|
||||||
const subscription = ref<ISubscription | null>(null)
|
const subscription = ref<ISubscription | null>(null)
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
subscription.value = props.namespace.subscription
|
subscription.value = props.namespace.subscription
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function setSubscriptionInStore(sub: ISubscription) {
|
||||||
|
subscription.value = sub
|
||||||
|
namespaceStore.setNamespaces([
|
||||||
|
{
|
||||||
|
...props.namespace,
|
||||||
|
subscription: sub,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -43,7 +43,7 @@ export const useNamespaceStore = defineStore('namespace', {
|
||||||
getNamespaceById: state => (namespaceId: INamespace['id']) => {
|
getNamespaceById: state => (namespaceId: INamespace['id']) => {
|
||||||
return state.namespaces.find(({id}) => id == namespaceId) || null
|
return state.namespaces.find(({id}) => id == namespaceId) || null
|
||||||
},
|
},
|
||||||
|
|
||||||
searchNamespace() {
|
searchNamespace() {
|
||||||
return (query: string) => (
|
return (query: string) => (
|
||||||
search(query)
|
search(query)
|
||||||
|
@ -64,6 +64,13 @@ export const useNamespaceStore = defineStore('namespace', {
|
||||||
this.namespaces = namespaces
|
this.namespaces = namespaces
|
||||||
namespaces.forEach(n => {
|
namespaces.forEach(n => {
|
||||||
add(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
|
// support hot reloading
|
||||||
if (import.meta.hot) {
|
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