From c249fb886a98e7a1b287400b1ec008da53403e1a Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Mon, 28 Aug 2023 23:55:41 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20(user=20settings)=20eager?= =?UTF-8?q?=20api=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/repo/store/userRepo.store.ts | 32 ++++++++++++++---------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/modules/repo/store/userRepo.store.ts b/src/modules/repo/store/userRepo.store.ts index 59262d7..9e4aca0 100644 --- a/src/modules/repo/store/userRepo.store.ts +++ b/src/modules/repo/store/userRepo.store.ts @@ -42,21 +42,27 @@ export const useUserRepoStore = defineStore({ 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) => { - this.readme = readme + getCachedMainReadme(newUser, newRepo) + .then((readme) => { + this.readme = readme + }) + .then(() => getMainReadme(newUser, newRepo)) + .then((readme) => { + this.readme = readme - // if the offline state is too quick, - // it gives more the impression of glitch. - setTimeout(() => { - this.isReadmeOffline = false - }, 500) - }) - - const files = await getFiles(newUser, newRepo) - this.files = files - this.userSettings = await getUserSettingsContent(newUser, newRepo, files) + // if the offline state is too quick, + // it gives an impression of glitch. + setTimeout(() => { + this.isReadmeOffline = false + }, 500) + }) }, resetUserRepo() { this.user = ''