From 111794a40b196e2eafc46b8eaa01ebda588ce271 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sun, 13 Aug 2023 21:22:33 +0200 Subject: [PATCH] display if readme is from cache or network --- src/assets/icons/offline.svg | 8 ++++++++ src/components/FluxNote.vue | 12 ++++++++++++ src/modules/repo/store/userRepo.store.ts | 9 +++++---- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/assets/icons/offline.svg diff --git a/src/assets/icons/offline.svg b/src/assets/icons/offline.svg new file mode 100644 index 0000000..a4b58f3 --- /dev/null +++ b/src/assets/icons/offline.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/components/FluxNote.vue b/src/components/FluxNote.vue index d66d635..cedb04f 100644 --- a/src/components/FluxNote.vue +++ b/src/components/FluxNote.vue @@ -106,6 +106,11 @@ const focus = () => scrollToFocusedNote(undefined, true) @click="resetStackedNotes" >{{ repo }}] + ofline

{{ user }} @@ -184,6 +189,13 @@ $header-height: 40px; .subtitle { text-align: center; } + + .title { + img { + position: absolute; + right: 0; + } + } } } diff --git a/src/modules/repo/store/userRepo.store.ts b/src/modules/repo/store/userRepo.store.ts index e77a709..281478f 100644 --- a/src/modules/repo/store/userRepo.store.ts +++ b/src/modules/repo/store/userRepo.store.ts @@ -13,6 +13,7 @@ interface State { user: string repo: string files: RepoFile[] + isReadmeOffline: boolean readme?: string | null userSettings?: UserSettings | null needToLogin: boolean @@ -24,12 +25,14 @@ export const useUserRepoStore = defineStore({ user: '', repo: '', files: [], + isReadmeOffline: true, readme: undefined, userSettings: undefined, needToLogin: false }), actions: { async setUserRepo(newUser: string, newRepo: string) { + this.isReadmeOffline = true this.user = newUser this.repo = newRepo try { @@ -37,17 +40,15 @@ export const useUserRepoStore = defineStore({ } catch (error) { console.warn('impossible to refresh token') } - const [cachedReadme] = await Promise.all([ - getCachedMainReadme(newUser, newRepo) - ]) - this.readme = cachedReadme + this.readme = await getCachedMainReadme(newUser, newRepo) const [readme, files] = await Promise.all([ getMainReadme(newUser, newRepo), getFiles(newUser, newRepo) ]) this.readme = readme + this.isReadmeOffline = false this.files = files this.userSettings = await getUserSettingsContent(newUser, newRepo, files)