From c02a0c85d081dc02a3ceb6d9d6aed068476336eb Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Thu, 17 Aug 2023 10:42:40 +0200 Subject: [PATCH] trying to be as little blocking as possible --- src/modules/repo/store/userRepo.store.ts | 23 +++++++++++------------ src/modules/user/service/signIn.ts | 4 ++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/modules/repo/store/userRepo.store.ts b/src/modules/repo/store/userRepo.store.ts index ecbad4e..59262d7 100644 --- a/src/modules/repo/store/userRepo.store.ts +++ b/src/modules/repo/store/userRepo.store.ts @@ -44,19 +44,18 @@ export const useUserRepoStore = defineStore({ this.readme = await getCachedMainReadme(newUser, newRepo) - const [readme, files] = await Promise.all([ - getMainReadme(newUser, newRepo), - getFiles(newUser, newRepo) - ]) - this.readme = readme + 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 - - // if the offline state is too quick, - // it gives more the impression of glitch. - setTimeout(() => { - this.isReadmeOffline = false - }, 500) - this.userSettings = await getUserSettingsContent(newUser, newRepo, files) }, resetUserRepo() { diff --git a/src/modules/user/service/signIn.ts b/src/modules/user/service/signIn.ts index fa12086..2d9e94f 100644 --- a/src/modules/user/service/signIn.ts +++ b/src/modules/user/service/signIn.ts @@ -33,9 +33,9 @@ export const needToRefreshToken = async () => { } const expirationDate = new Date(accessToken.expirationDate) - const dateToCompare = addMinutes(new Date(), 15) + const minimumViableDate = addMinutes(new Date(), 15) - return isBefore(expirationDate, dateToCompare) + return isBefore(expirationDate, minimumViableDate) } export const refreshToken = async () => {