diff --git a/src/stores/auth.ts b/src/stores/auth.ts index 62ec7acf2..e355737aa 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -286,7 +286,7 @@ export const useAuthStore = defineStore('auth', () => { async function verifyEmail(): Promise { const emailVerifyToken = localStorage.getItem('emailConfirmToken') if (emailVerifyToken) { - const stopLoading = setModuleLoading(this, setIsLoading) + const stopLoading = setModuleLoading(setIsLoading) try { await HTTPFactory().post('user/confirm', {token: emailVerifyToken}) return true @@ -309,7 +309,7 @@ export const useAuthStore = defineStore('auth', () => { }) { const userSettingsService = new UserSettingsService() - const cancel = setModuleLoading(this, setIsLoadingGeneralSettings) + const cancel = setModuleLoading(setIsLoadingGeneralSettings) try { saveLanguage(settings.language) await userSettingsService.update(settings) diff --git a/src/stores/helper.ts b/src/stores/helper.ts index ea9dff6f2..857f9500b 100644 --- a/src/stores/helper.ts +++ b/src/stores/helper.ts @@ -1,23 +1,9 @@ -export interface LoadingState { - isLoading: boolean -} - const LOADING_TIMEOUT = 100 -export const setModuleLoading = (store: Store, loadFunc : ((isLoading: boolean) => void) | null = null) => { - const timeout = setTimeout(() => { - if (loadFunc === null) { - store.isLoading = true - } else { - loadFunc(true) - } - }, LOADING_TIMEOUT) +export function setModuleLoading(loadFunc: (isLoading: boolean) => void) { + const timeout = setTimeout(() => loadFunc(true), LOADING_TIMEOUT) return () => { clearTimeout(timeout) - if (loadFunc === null) { - store.isLoading = false - } else { - loadFunc(false) - } + loadFunc(false) } } \ No newline at end of file diff --git a/src/stores/kanban.ts b/src/stores/kanban.ts index 629c3a637..a5d89f359 100644 --- a/src/stores/kanban.ts +++ b/src/stores/kanban.ts @@ -224,7 +224,7 @@ export const useKanbanStore = defineStore('kanban', () => { } async function loadBucketsForList({listId, params}: {listId: IList['id'], params}) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) // Clear everything to prevent having old buckets in the list if loading the buckets from this list takes a few moments setBuckets([]) @@ -259,7 +259,7 @@ export const useKanbanStore = defineStore('kanban', () => { return } - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) setBucketLoading({bucketId: bucketId, loading: true}) const params = JSON.parse(JSON.stringify(ps)) @@ -302,7 +302,7 @@ export const useKanbanStore = defineStore('kanban', () => { } async function createBucket(bucket: IBucket) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const bucketService = new BucketService() try { @@ -315,7 +315,7 @@ export const useKanbanStore = defineStore('kanban', () => { } async function deleteBucket({bucket, params}: {bucket: IBucket, params}) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const bucketService = new BucketService() try { @@ -330,7 +330,7 @@ export const useKanbanStore = defineStore('kanban', () => { } async function updateBucket(updatedBucketData: Partial) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const bucketIndex = findIndexById(buckets.value, updatedBucketData.id) const oldBucket = cloneDeep(buckets.value[bucketIndex]) diff --git a/src/stores/labels.ts b/src/stores/labels.ts index b05b8b0db..365aa7628 100644 --- a/src/stores/labels.ts +++ b/src/stores/labels.ts @@ -81,7 +81,7 @@ export const useLabelStore = defineStore('label', () => { return } - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) try { const newLabels = await getAllLabels() @@ -93,7 +93,7 @@ export const useLabelStore = defineStore('label', () => { } async function deleteLabel(label: ILabel) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const labelService = new LabelService() try { @@ -107,7 +107,7 @@ export const useLabelStore = defineStore('label', () => { } async function updateLabel(label: ILabel) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const labelService = new LabelService() try { @@ -121,7 +121,7 @@ export const useLabelStore = defineStore('label', () => { } async function createLabel(label: ILabel) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const labelService = new LabelService() try { diff --git a/src/stores/lists.ts b/src/stores/lists.ts index e03eac826..09cdccf4c 100644 --- a/src/stores/lists.ts +++ b/src/stores/lists.ts @@ -95,7 +95,7 @@ export const useListStore = defineStore('list', () => { } async function createList(list: IList) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const listService = new ListService() try { @@ -110,7 +110,7 @@ export const useListStore = defineStore('list', () => { } async function updateList(list: IList) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const listService = new ListService() try { @@ -145,7 +145,7 @@ export const useListStore = defineStore('list', () => { } async function deleteList(list: IList) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const listService = new ListService() try { diff --git a/src/stores/namespaces.ts b/src/stores/namespaces.ts index db75eae1a..aa35f1606 100644 --- a/src/stores/namespaces.ts +++ b/src/stores/namespaces.ts @@ -148,7 +148,7 @@ export const useNamespaceStore = defineStore('namespace', () => { } async function loadNamespaces() { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const namespaceService = new NamespaceService() try { @@ -182,7 +182,7 @@ export const useNamespaceStore = defineStore('namespace', () => { } async function deleteNamespace(namespace: INamespace) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const namespaceService = new NamespaceService() try { @@ -195,7 +195,7 @@ export const useNamespaceStore = defineStore('namespace', () => { } async function createNamespace(namespace: INamespace) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const namespaceService = new NamespaceService() try { diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index 124c597cb..56eeb8dcd 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -104,7 +104,7 @@ export const useTaskStore = defineStore('task', () => { async function loadTasks(params) { const taskService = new TaskService() - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) try { tasks.value = await taskService.getAll({}, params) baseStore.setHasTasks(tasks.value.length > 0) @@ -115,7 +115,7 @@ export const useTaskStore = defineStore('task', () => { } async function update(task: ITask) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const taskService = new TaskService() try { @@ -172,7 +172,7 @@ export const useTaskStore = defineStore('task', () => { user: IUser, taskId: ITask['id'] }) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) try { const taskAssigneeService = new TaskAssigneeService() @@ -370,7 +370,7 @@ export const useTaskStore = defineStore('task', () => { } : Partial, ) { - const cancel = setModuleLoading(this, setIsLoading) + const cancel = setModuleLoading(setIsLoading) const parsedTask = parseTaskText(title, getQuickAddMagicMode()) const foundListId = await findListId({