fix: remove vuex leftover from setModuleLoading
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dominik Pschenitschni 2022-11-15 22:36:23 +01:00
parent bcb5190365
commit 68d930f71b
Signed by: dpschen
GPG Key ID: B257AC0149F43A77
7 changed files with 24 additions and 38 deletions

View File

@ -285,7 +285,7 @@ export const useAuthStore = defineStore('auth', () => {
async function verifyEmail(): Promise<boolean> {
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
@ -308,7 +308,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)

View File

@ -1,23 +1,9 @@
export interface LoadingState {
isLoading: boolean
}
const LOADING_TIMEOUT = 100
export const setModuleLoading = <Store extends LoadingState>(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)
}
}

View File

@ -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<IBucket>) {
const cancel = setModuleLoading(this, setIsLoading)
const cancel = setModuleLoading(setIsLoading)
const bucketIndex = findIndexById(buckets.value, updatedBucketData.id)
const oldBucket = cloneDeep(buckets.value[bucketIndex])

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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<ITask>,
) {
const cancel = setModuleLoading(this, setIsLoading)
const cancel = setModuleLoading(setIsLoading)
const parsedTask = parseTaskText(title, getQuickAddMagicMode())
const foundListId = await findListId({