From 326effb7febd4ff051912e11555ea0bf7d2b0b3c Mon Sep 17 00:00:00 2001 From: Reza Soltani Date: Tue, 28 Nov 2023 13:31:08 +0330 Subject: [PATCH] refactor bookmark.getAll --- bookmarks/vanilla/src/modules/Bookmark.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bookmarks/vanilla/src/modules/Bookmark.ts b/bookmarks/vanilla/src/modules/Bookmark.ts index 62541a1c..683c79ef 100644 --- a/bookmarks/vanilla/src/modules/Bookmark.ts +++ b/bookmarks/vanilla/src/modules/Bookmark.ts @@ -87,8 +87,8 @@ export class Bookmark { */ public static async getAll(session: Session) { const indexUrls = await this.getIndexUrl(session); - const all = indexUrls.map(async (indexUrl) => { - try { + try { + const all = indexUrls.map(async (indexUrl) => { const ds = await getSolidDataset(indexUrl, { fetch: session.fetch }); const things = getThingAll(ds) @@ -96,13 +96,14 @@ export class Bookmark { const bookmarks = await things.map(thing => this.mapBookmark(thing)) return bookmarks - } catch (error) { - return [] - } - }) - const allPromise = Promise.all([...all]); - const values = (await allPromise).flat(); - return values; + }) + const allPromise = Promise.all([...all]); + const values = (await allPromise).flat(); + return values; + } catch (error) { + return [] + } + } /**