display if readme is from cache or network

This commit is contained in:
Julien Calixte
2023-08-13 21:22:33 +02:00
parent 133a998ef8
commit 111794a40b
3 changed files with 25 additions and 4 deletions

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-wifi-off" width="30" height="30" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3a47" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M12 18l.01 0" />
<path d="M9.172 15.172a4 4 0 0 1 5.656 0" />
<path d="M6.343 12.343a7.963 7.963 0 0 1 3.864 -2.14m4.163 .155a7.965 7.965 0 0 1 3.287 2" />
<path d="M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374" />
<path d="M3 3l18 18" />
</svg>

After

Width:  |  Height:  |  Size: 571 B

View File

@@ -106,6 +106,11 @@ const focus = () => scrollToFocusedNote(undefined, true)
@click="resetStackedNotes" @click="resetStackedNotes"
>{{ repo }}</router-link >{{ repo }}</router-link
>] >]
<img
v-if="store.isReadmeOffline"
src="@/assets/icons/offline.svg"
alt="ofline"
/>
</h1> </h1>
<h4 class="subtitle is-4"> <h4 class="subtitle is-4">
<em>{{ user }}</em> <em>{{ user }}</em>
@@ -184,6 +189,13 @@ $header-height: 40px;
.subtitle { .subtitle {
text-align: center; text-align: center;
} }
.title {
img {
position: absolute;
right: 0;
}
}
} }
} }

View File

@@ -13,6 +13,7 @@ interface State {
user: string user: string
repo: string repo: string
files: RepoFile[] files: RepoFile[]
isReadmeOffline: boolean
readme?: string | null readme?: string | null
userSettings?: UserSettings | null userSettings?: UserSettings | null
needToLogin: boolean needToLogin: boolean
@@ -24,12 +25,14 @@ export const useUserRepoStore = defineStore({
user: '', user: '',
repo: '', repo: '',
files: [], files: [],
isReadmeOffline: true,
readme: undefined, readme: undefined,
userSettings: undefined, userSettings: undefined,
needToLogin: false needToLogin: false
}), }),
actions: { actions: {
async setUserRepo(newUser: string, newRepo: string) { async setUserRepo(newUser: string, newRepo: string) {
this.isReadmeOffline = true
this.user = newUser this.user = newUser
this.repo = newRepo this.repo = newRepo
try { try {
@@ -37,17 +40,15 @@ export const useUserRepoStore = defineStore({
} catch (error) { } catch (error) {
console.warn('impossible to refresh token') 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([ const [readme, files] = await Promise.all([
getMainReadme(newUser, newRepo), getMainReadme(newUser, newRepo),
getFiles(newUser, newRepo) getFiles(newUser, newRepo)
]) ])
this.readme = readme this.readme = readme
this.isReadmeOffline = false
this.files = files this.files = files
this.userSettings = await getUserSettingsContent(newUser, newRepo, files) this.userSettings = await getUserSettingsContent(newUser, newRepo, files)