️ (user settings) eager api call

This commit is contained in:
Julien Calixte
2023-08-28 23:55:41 +02:00
parent 49d2571f5f
commit c249fb886a

View File

@@ -42,21 +42,27 @@ export const useUserRepoStore = defineStore({
console.warn('impossible to refresh token') console.warn('impossible to refresh token')
} }
this.readme = await getCachedMainReadme(newUser, newRepo) getFiles(newUser, newRepo)
.then((files) => {
this.files = files
return getUserSettingsContent(newUser, newRepo, files)
})
.then((userSettings) => (this.userSettings = userSettings))
getMainReadme(newUser, newRepo).then((readme) => { getCachedMainReadme(newUser, newRepo)
.then((readme) => {
this.readme = readme
})
.then(() => getMainReadme(newUser, newRepo))
.then((readme) => {
this.readme = readme this.readme = readme
// if the offline state is too quick, // if the offline state is too quick,
// it gives more the impression of glitch. // it gives an impression of glitch.
setTimeout(() => { setTimeout(() => {
this.isReadmeOffline = false this.isReadmeOffline = false
}, 500) }, 500)
}) })
const files = await getFiles(newUser, newRepo)
this.files = files
this.userSettings = await getUserSettingsContent(newUser, newRepo, files)
}, },
resetUserRepo() { resetUserRepo() {
this.user = '' this.user = ''