From f34b25bd95812ff08c00375b182323f8ac81a485 Mon Sep 17 00:00:00 2001 From: ludchieng Date: Tue, 24 Jan 2023 23:17:15 +0100 Subject: [PATCH] fix: store won't initialize correctly --- src/utils/localstore/synchronizer.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/localstore/synchronizer.ts b/src/utils/localstore/synchronizer.ts index 6128bc9..4746d80 100644 --- a/src/utils/localstore/synchronizer.ts +++ b/src/utils/localstore/synchronizer.ts @@ -8,11 +8,11 @@ export const lastUpdatedAt = () => { export const synchronize = async () => { const lines = await synchronizeFile('/schemas/lines.json', 'lines') - - for (const line of Object.values(lines) as any[]) { - synchronizeLine(line.slugName) - } - localStorage.setItem('lines.updatedAt', new Date().toISOString()) + return Promise.all( + Object.values(lines).map((line: any) => synchronizeLine(line.slugName)), + ).then(() => { + localStorage.setItem('lines.updatedAt', new Date().toISOString()) + }) } export const synchronizeLine = async (line: string) => {