From 0595413260f44d5ab82cc57e834a5786c0ad2379 Mon Sep 17 00:00:00 2001 From: Benny Guo Date: Sat, 12 Aug 2023 19:57:47 +0800 Subject: [PATCH] fix: gitalk loading state not closed when recent comments are loaded resolved: #290 #280 --- src/components/Sidebar/src/RecentComment.vue | 4 +--- src/hooks/useCommentPlugin.ts | 25 +++++++------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/components/Sidebar/src/RecentComment.vue b/src/components/Sidebar/src/RecentComment.vue index dd565f4c..3f2c84a6 100644 --- a/src/components/Sidebar/src/RecentComment.vue +++ b/src/components/Sidebar/src/RecentComment.vue @@ -129,9 +129,7 @@ export default defineComponent({ return { SvgTypes, isLoading: computed(() => commentPluginLoading.value), - comments: computed(() => { - return recentComments.value - }), + comments: computed(() => recentComments.value), isConfigReady: computed(() => appStore.configReady), fetchRecentComment, enabledCommentPlugin, diff --git a/src/hooks/useCommentPlugin.ts b/src/hooks/useCommentPlugin.ts index 3abd5a73..e1fb2f96 100644 --- a/src/hooks/useCommentPlugin.ts +++ b/src/hooks/useCommentPlugin.ts @@ -83,7 +83,7 @@ export default function useCommentPlugin() { /** * Fetching recent comments data base on comment plugin */ - const fetchRecentComment = () => { + const fetchRecentComment = async () => { const enabledPlugin = computed(() => { const result = enabledCommentPlugin.value return result.plugin !== '' && !!result.recentComment @@ -109,9 +109,8 @@ export default function useCommentPlugin() { admin: appStore.themeConfig.plugins.gitalk.admin[0] }) - githubComments.getComments().then(response => { - recentComments.value = response - }) + recentComments.value = await githubComments.getComments() + commentPluginLoading.value = false break @@ -124,10 +123,8 @@ export default function useCommentPlugin() { lang: appStore.themeConfig.plugins.valine.lang }) - leadCloudComments.getRecentComments(7).then(res => { - recentComments.value = res - commentPluginLoading.value = false - }) + recentComments.value = await leadCloudComments.getRecentComments(7) + commentPluginLoading.value = false break @@ -137,10 +134,8 @@ export default function useCommentPlugin() { lang: appStore.themeConfig.plugins.twikoo.lang }) - twikooComments.getRecentComments(7).then(res => { - recentComments.value = res - commentPluginLoading.value = false - }) + recentComments.value = await twikooComments.getRecentComments(7) + commentPluginLoading.value = false break @@ -150,10 +145,8 @@ export default function useCommentPlugin() { lang: appStore.locale ?? 'en' }) - walineComments.getRecentComments(7).then(res => { - recentComments.value = res - commentPluginLoading.value = false - }) + recentComments.value = await walineComments.getRecentComments(7) + commentPluginLoading.value = false break