Skip to content

Commit

Permalink
Fixed the loading could not be closed correctly (#77)
Browse files Browse the repository at this point in the history
* Fix hide loading before show it

* Release hotfix
  • Loading branch information
hayden-fr authored Dec 6, 2024
1 parent 00d23ff commit 5c01713
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-model-manager"
description = "Manage models: browsing, download and delete."
version = "2.1.4"
version = "2.1.5"
license = "LICENSE"
dependencies = ["markdownify"]

Expand Down
16 changes: 8 additions & 8 deletions src/hooks/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ declare module 'hooks/store' {
}

export const useLoading = () => {
const timer = ref<NodeJS.Timeout>()
const targetTimer = ref<Record<string, NodeJS.Timeout | undefined>>({})

const show = () => {
timer.value = setTimeout(() => {
timer.value = undefined
const show = (target: string = '_default') => {
targetTimer.value[target] = setTimeout(() => {
targetTimer.value[target] = undefined
globalLoading.show()
}, 200)
}

const hide = () => {
if (timer.value) {
clearTimeout(timer.value)
timer.value = undefined
const hide = (target: string = '_default') => {
if (targetTimer.value) {
clearTimeout(targetTimer.value[target])
targetTimer.value[target] = undefined
} else {
globalLoading.hide()
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export const useModels = defineStore('models', (store) => {
const models = ref<Record<string, Model[]>>({})

const refreshModels = async (folder: string) => {
loading.show()
loading.show(folder)
return request(`/models/${folder}`)
.then((resData) => {
models.value[folder] = resData
return resData
})
.finally(() => {
loading.hide()
loading.hide(folder)
})
}

Expand Down

0 comments on commit 5c01713

Please sign in to comment.