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> { async function verifyEmail(): Promise<boolean> {
const emailVerifyToken = localStorage.getItem('emailConfirmToken') const emailVerifyToken = localStorage.getItem('emailConfirmToken')
if (emailVerifyToken) { if (emailVerifyToken) {
const stopLoading = setModuleLoading(this, setIsLoading) const stopLoading = setModuleLoading(setIsLoading)
try { try {
await HTTPFactory().post('user/confirm', {token: emailVerifyToken}) await HTTPFactory().post('user/confirm', {token: emailVerifyToken})
return true return true
@ -308,7 +308,7 @@ export const useAuthStore = defineStore('auth', () => {
}) { }) {
const userSettingsService = new UserSettingsService() const userSettingsService = new UserSettingsService()
const cancel = setModuleLoading(this, setIsLoadingGeneralSettings) const cancel = setModuleLoading(setIsLoadingGeneralSettings)
try { try {
saveLanguage(settings.language) saveLanguage(settings.language)
await userSettingsService.update(settings) await userSettingsService.update(settings)

View File

@ -1,23 +1,9 @@
export interface LoadingState {
isLoading: boolean
}
const LOADING_TIMEOUT = 100 const LOADING_TIMEOUT = 100
export const setModuleLoading = <Store extends LoadingState>(store: Store, loadFunc : ((isLoading: boolean) => void) | null = null) => { export function setModuleLoading(loadFunc: (isLoading: boolean) => void) {
const timeout = setTimeout(() => { const timeout = setTimeout(() => loadFunc(true), LOADING_TIMEOUT)
if (loadFunc === null) {
store.isLoading = true
} else {
loadFunc(true)
}
}, LOADING_TIMEOUT)
return () => { return () => {
clearTimeout(timeout) clearTimeout(timeout)
if (loadFunc === null) { loadFunc(false)
store.isLoading = false
} else {
loadFunc(false)
}
} }
} }

View File

@ -224,7 +224,7 @@ export const useKanbanStore = defineStore('kanban', () => {
} }
async function loadBucketsForList({listId, params}: {listId: IList['id'], params}) { 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 // Clear everything to prevent having old buckets in the list if loading the buckets from this list takes a few moments
setBuckets([]) setBuckets([])
@ -259,7 +259,7 @@ export const useKanbanStore = defineStore('kanban', () => {
return return
} }
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
setBucketLoading({bucketId: bucketId, loading: true}) setBucketLoading({bucketId: bucketId, loading: true})
const params = JSON.parse(JSON.stringify(ps)) const params = JSON.parse(JSON.stringify(ps))
@ -302,7 +302,7 @@ export const useKanbanStore = defineStore('kanban', () => {
} }
async function createBucket(bucket: IBucket) { async function createBucket(bucket: IBucket) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const bucketService = new BucketService() const bucketService = new BucketService()
try { try {
@ -315,7 +315,7 @@ export const useKanbanStore = defineStore('kanban', () => {
} }
async function deleteBucket({bucket, params}: {bucket: IBucket, params}) { async function deleteBucket({bucket, params}: {bucket: IBucket, params}) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const bucketService = new BucketService() const bucketService = new BucketService()
try { try {
@ -330,7 +330,7 @@ export const useKanbanStore = defineStore('kanban', () => {
} }
async function updateBucket(updatedBucketData: Partial<IBucket>) { async function updateBucket(updatedBucketData: Partial<IBucket>) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const bucketIndex = findIndexById(buckets.value, updatedBucketData.id) const bucketIndex = findIndexById(buckets.value, updatedBucketData.id)
const oldBucket = cloneDeep(buckets.value[bucketIndex]) const oldBucket = cloneDeep(buckets.value[bucketIndex])

View File

@ -81,7 +81,7 @@ export const useLabelStore = defineStore('label', () => {
return return
} }
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
try { try {
const newLabels = await getAllLabels() const newLabels = await getAllLabels()
@ -93,7 +93,7 @@ export const useLabelStore = defineStore('label', () => {
} }
async function deleteLabel(label: ILabel) { async function deleteLabel(label: ILabel) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const labelService = new LabelService() const labelService = new LabelService()
try { try {
@ -107,7 +107,7 @@ export const useLabelStore = defineStore('label', () => {
} }
async function updateLabel(label: ILabel) { async function updateLabel(label: ILabel) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const labelService = new LabelService() const labelService = new LabelService()
try { try {
@ -121,7 +121,7 @@ export const useLabelStore = defineStore('label', () => {
} }
async function createLabel(label: ILabel) { async function createLabel(label: ILabel) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const labelService = new LabelService() const labelService = new LabelService()
try { try {

View File

@ -95,7 +95,7 @@ export const useListStore = defineStore('list', () => {
} }
async function createList(list: IList) { async function createList(list: IList) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const listService = new ListService() const listService = new ListService()
try { try {
@ -110,7 +110,7 @@ export const useListStore = defineStore('list', () => {
} }
async function updateList(list: IList) { async function updateList(list: IList) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const listService = new ListService() const listService = new ListService()
try { try {
@ -145,7 +145,7 @@ export const useListStore = defineStore('list', () => {
} }
async function deleteList(list: IList) { async function deleteList(list: IList) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const listService = new ListService() const listService = new ListService()
try { try {

View File

@ -148,7 +148,7 @@ export const useNamespaceStore = defineStore('namespace', () => {
} }
async function loadNamespaces() { async function loadNamespaces() {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const namespaceService = new NamespaceService() const namespaceService = new NamespaceService()
try { try {
@ -182,7 +182,7 @@ export const useNamespaceStore = defineStore('namespace', () => {
} }
async function deleteNamespace(namespace: INamespace) { async function deleteNamespace(namespace: INamespace) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const namespaceService = new NamespaceService() const namespaceService = new NamespaceService()
try { try {
@ -195,7 +195,7 @@ export const useNamespaceStore = defineStore('namespace', () => {
} }
async function createNamespace(namespace: INamespace) { async function createNamespace(namespace: INamespace) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const namespaceService = new NamespaceService() const namespaceService = new NamespaceService()
try { try {

View File

@ -104,7 +104,7 @@ export const useTaskStore = defineStore('task', () => {
async function loadTasks(params) { async function loadTasks(params) {
const taskService = new TaskService() const taskService = new TaskService()
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
try { try {
tasks.value = await taskService.getAll({}, params) tasks.value = await taskService.getAll({}, params)
baseStore.setHasTasks(tasks.value.length > 0) baseStore.setHasTasks(tasks.value.length > 0)
@ -115,7 +115,7 @@ export const useTaskStore = defineStore('task', () => {
} }
async function update(task: ITask) { async function update(task: ITask) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const taskService = new TaskService() const taskService = new TaskService()
try { try {
@ -172,7 +172,7 @@ export const useTaskStore = defineStore('task', () => {
user: IUser, user: IUser,
taskId: ITask['id'] taskId: ITask['id']
}) { }) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
try { try {
const taskAssigneeService = new TaskAssigneeService() const taskAssigneeService = new TaskAssigneeService()
@ -370,7 +370,7 @@ export const useTaskStore = defineStore('task', () => {
} : } :
Partial<ITask>, Partial<ITask>,
) { ) {
const cancel = setModuleLoading(this, setIsLoading) const cancel = setModuleLoading(setIsLoading)
const parsedTask = parseTaskText(title, getQuickAddMagicMode()) const parsedTask = parseTaskText(title, getQuickAddMagicMode())
const foundListId = await findListId({ const foundListId = await findListId({