From 1c58fccd926586b2303ce41939a535b2044a78a9 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Wed, 21 Sep 2022 22:45:11 +0200 Subject: [PATCH 1/3] feat: add hot reloading support --- src/stores/labels.ts | 7 ++++++- src/stores/lists.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/stores/labels.ts b/src/stores/labels.ts index 8d2a8f5a3..ff43cb35c 100644 --- a/src/stores/labels.ts +++ b/src/stores/labels.ts @@ -1,4 +1,4 @@ -import { defineStore } from 'pinia' +import { acceptHMRUpdate, defineStore } from 'pinia' import LabelService from '@/services/label' import {success} from '@/message' @@ -134,3 +134,8 @@ export const useLabelStore = defineStore('label', { }, }, }) + +// support hot reloading +if (import.meta.hot) { + import.meta.hot.accept(acceptHMRUpdate(useLabelStore, import.meta.hot)) +} \ No newline at end of file diff --git a/src/stores/lists.ts b/src/stores/lists.ts index b12923cd1..36f7b96b7 100644 --- a/src/stores/lists.ts +++ b/src/stores/lists.ts @@ -1,5 +1,5 @@ import {watch, reactive, shallowReactive, unref, toRefs, readonly} from 'vue' -import {defineStore} from 'pinia' +import {acceptHMRUpdate, defineStore} from 'pinia' import {useI18n} from 'vue-i18n' import ListService from '@/services/list' @@ -179,4 +179,9 @@ export function useList(listId: MaybeRef) { list, save, } +} + +// support hot reloading +if (import.meta.hot) { + import.meta.hot.accept(acceptHMRUpdate(useListStore, import.meta.hot)) } \ No newline at end of file From 9474240cb9159a0e1b42f82cb492cc267782ce4f Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Fri, 2 Sep 2022 10:20:25 +0200 Subject: [PATCH 2/3] feat: move namespaces store to stores --- src/store/index.ts | 2 -- src/{store/modules => stores}/namespaces.ts | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) rename src/{store/modules => stores}/namespaces.ts (98%) diff --git a/src/store/index.ts b/src/store/index.ts index 605d070a0..6fa534079 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -15,7 +15,6 @@ import { } from './mutation-types' import config from './modules/config' import auth from './modules/auth' -import namespaces from './modules/namespaces' import kanban from './modules/kanban' import tasks from './modules/tasks' import attachments from './modules/attachments' @@ -39,7 +38,6 @@ export const store = createStore({ modules: { config, auth, - namespaces, kanban, tasks, attachments, diff --git a/src/store/modules/namespaces.ts b/src/stores/namespaces.ts similarity index 98% rename from src/store/modules/namespaces.ts rename to src/stores/namespaces.ts index 74545a35a..ed7eb9916 100644 --- a/src/store/modules/namespaces.ts +++ b/src/stores/namespaces.ts @@ -1,6 +1,6 @@ import type { Module } from 'vuex' -import NamespaceService from '../../services/namespace' +import NamespaceService from '../services/namespace' import {setLoading} from '@/store/helper' import {createNewIndexer} from '@/indexes' import type {NamespaceState, RootStoreState} from '@/store/types' From 093ab766d45247b3b1d12740dc6b24c6b48f21c4 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Fri, 2 Sep 2022 11:15:29 +0200 Subject: [PATCH 3/3] feat: port namespace store to pinia --- src/components/home/navigation.vue | 10 +- src/components/tasks/partials/listSearch.vue | 8 +- .../tasks/partials/relatedTasks.vue | 5 +- .../tasks/partials/singleTaskInList.vue | 4 +- src/composables/useNamespaceSearch.ts | 8 +- src/models/savedFilter.ts | 2 +- src/store/types.ts | 1 + src/stores/lists.ts | 19 +- src/stores/namespaces.ts | 227 ++++++++++-------- src/views/Home.vue | 6 +- src/views/filters/FilterDelete.vue | 5 +- src/views/filters/FilterEdit.vue | 7 +- src/views/filters/FilterNew.vue | 6 +- src/views/list/settings/duplicate.vue | 10 +- src/views/migrator/MigrateService.vue | 4 +- src/views/namespaces/ListNamespaces.vue | 6 +- src/views/namespaces/NewNamespace.vue | 4 +- src/views/namespaces/settings/archive.vue | 15 +- src/views/namespaces/settings/delete.vue | 15 +- src/views/namespaces/settings/edit.vue | 6 +- src/views/tasks/TaskDetailView.vue | 12 +- 21 files changed, 214 insertions(+), 166 deletions(-) diff --git a/src/components/home/navigation.vue b/src/components/home/navigation.vue index 2e5947714..f7f8f7f2f 100644 --- a/src/components/home/navigation.vue +++ b/src/components/home/navigation.vue @@ -160,6 +160,7 @@ import type {IList} from '@/modelTypes/IList' import type {INamespace} from '@/modelTypes/INamespace' import ColorBubble from '@/components/misc/colorBubble.vue' import {useListStore} from '@/stores/lists' +import {useNamespaceStore} from '@/stores/namespaces' const drag = ref(false) const dragOptions = { @@ -168,13 +169,14 @@ const dragOptions = { } const store = useStore() +const namespaceStore = useNamespaceStore() const currentList = computed(() => store.state.currentList) const menuActive = computed(() => store.state.menuActive) -const loading = computed(() => store.state.loading && store.state.loadingModule === 'namespaces') +const loading = computed(() => namespaceStore.isLoading) const namespaces = computed(() => { - return (store.state.namespaces.namespaces as INamespace[]).filter(n => !n.isArchived) + return namespaceStore.namespaces.filter(n => !n.isArchived) }) const activeLists = computed(() => { return namespaces.value.map(({lists}) => { @@ -210,7 +212,7 @@ function toggleLists(namespaceId: INamespace['id']) { const listsVisible = ref<{ [id: INamespace['id']]: boolean }>({}) // FIXME: async action will be unfinished when component mounts onBeforeMount(async () => { - const namespaces = await store.dispatch('namespaces/loadNamespaces') as INamespace[] + const namespaces = await namespaceStore.loadNamespaces() namespaces.forEach(n => { if (typeof listsVisible.value[n.id] === 'undefined') { listsVisible.value[n.id] = true @@ -229,7 +231,7 @@ function updateActiveLists(namespace: INamespace, activeLists: IList[]) { ...namespace.lists.filter(l => l.isArchived), ] - store.commit('namespaces/setNamespaceById', { + namespaceStore.setNamespaceById({ ...namespace, lists, }) diff --git a/src/components/tasks/partials/listSearch.vue b/src/components/tasks/partials/listSearch.vue index 4a5e1b2e2..9ac59d669 100644 --- a/src/components/tasks/partials/listSearch.vue +++ b/src/components/tasks/partials/listSearch.vue @@ -19,12 +19,12 @@ diff --git a/src/views/list/settings/duplicate.vue b/src/views/list/settings/duplicate.vue index e4ed60724..bb784a8ae 100644 --- a/src/views/list/settings/duplicate.vue +++ b/src/views/list/settings/duplicate.vue @@ -22,7 +22,6 @@ @@ -21,11 +21,12 @@ import {ref, computed, watch, shallowReactive} from 'vue' import {useI18n} from 'vue-i18n' import {useRouter} from 'vue-router' -import {useStore} from '@/store' import {useTitle} from '@/composables/useTitle' import {success} from '@/message' +import {useNamespaceStore} from '@/stores/namespaces' import NamespaceModel from '@/models/namespace' import NamespaceService from '@/services/namespace' +import type { INamespace } from '@/modelTypes/INamespace' const props = defineProps({ namespaceId: { @@ -34,17 +35,17 @@ const props = defineProps({ }, }) -const store = useStore() -const router = useRouter() const {t} = useI18n({useScope: 'global'}) +const router = useRouter() +const namespaceStore = useNamespaceStore() const namespaceService = shallowReactive(new NamespaceService()) -const namespace = ref(new NamespaceModel()) +const namespace = ref(new NamespaceModel()) watch( () => props.namespaceId, async () => { - namespace.value = store.getters['namespaces/getNamespaceById'](props.namespaceId) + namespace.value = namespaceStore.getNamespaceById(props.namespaceId) || new NamespaceModel() // FIXME: ressouce should be loaded in store namespace.value = await namespaceService.get({id: props.namespaceId}) @@ -61,7 +62,7 @@ const title = computed(() => { useTitle(title) async function deleteNamespace() { - await store.dispatch('namespaces/deleteNamespace', namespace.value) + await namespaceStore.deleteNamespace(namespace.value) success({message: t('namespace.delete.success')}) router.push({name: 'home'}) } diff --git a/src/views/namespaces/settings/edit.vue b/src/views/namespaces/settings/edit.vue index 60596b286..2365f3310 100644 --- a/src/views/namespaces/settings/edit.vue +++ b/src/views/namespaces/settings/edit.vue @@ -57,7 +57,6 @@