Skip to content

Commit 245fb25

Browse files
committed
fix(code-space): prevent loader flicker when returning from other spaces
1 parent 9ca2612 commit 245fb25

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/renderer/components/sidebar/library/Library.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Archive, Inbox, Plus, Star, Trash } from 'lucide-vue-next'
1212
import { SplitterGroup, SplitterPanel, SplitterResizeHandle } from 'radix-vue'
1313
import { APP_DEFAULTS } from '~/main/store/constants'
1414
15-
const { state, isAppLoading } = useApp()
15+
const { state, isAppLoading, isCodeSpaceInitialized } = useApp()
1616
const {
1717
getSnippets,
1818
selectFirstSnippet,
@@ -79,6 +79,11 @@ async function initGetSnippets() {
7979
}
8080
8181
async function initApp() {
82+
if (isCodeSpaceInitialized.value) {
83+
isAppLoading.value = false
84+
return
85+
}
86+
8287
isAppLoading.value = true
8388
8489
const results = await Promise.allSettled([
@@ -92,6 +97,10 @@ async function initApp() {
9297
}
9398
})
9499
100+
isCodeSpaceInitialized.value = results.every(
101+
result => result.status === 'fulfilled',
102+
)
103+
95104
isAppLoading.value = false
96105
}
97106

src/renderer/composables/useApp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const focusedFolderId = ref<number | undefined>()
2828
const focusedSnippetId = ref<number | undefined>()
2929

3030
const isAppLoading = ref(true)
31+
const isCodeSpaceInitialized = ref(false)
3132
const isFocusedSnippetName = ref(false)
3233
const isFocusedSearch = ref(false)
3334
const isShowMarkdown = ref(false)
@@ -97,6 +98,7 @@ export function useApp() {
9798
focusedFolderId,
9899
focusedSnippetId,
99100
isAppLoading,
101+
isCodeSpaceInitialized,
100102
highlightedFolderIds,
101103
highlightedSnippetIds,
102104
highlightedTagId,

0 commit comments

Comments
 (0)