From 9b7f1be740c334416586d59de04d0c08f4df7eb5 Mon Sep 17 00:00:00 2001 From: Sag Date: Tue, 4 Jun 2024 08:20:32 +0200 Subject: [PATCH] Replaced Array.at() for better browser compatibility (#20315) fixes https://linear.app/tryghost/issue/SLO-125 - Array.at() has been introduced in ECMAScript 2022 and is currently not supported by older browsers, e.g. Safari < 15.4 --- apps/admin-x-framework/src/api/actions.ts | 2 +- apps/admin-x-framework/src/api/newsletters.ts | 2 +- apps/admin-x-framework/src/api/tiers.ts | 2 +- apps/admin-x-framework/src/api/users.ts | 2 +- apps/admin-x-framework/src/utils/api/updateQueries.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/admin-x-framework/src/api/actions.ts b/apps/admin-x-framework/src/api/actions.ts index e9f015bcde..43a00db4a5 100644 --- a/apps/admin-x-framework/src/api/actions.ts +++ b/apps/admin-x-framework/src/api/actions.ts @@ -78,7 +78,7 @@ export const useBrowseActions = createInfiniteQuery({ } }); - const meta = pages.at(-1)!.meta; + const meta = pages[pages.length - 1].meta; return { actions: actions.reverse(), diff --git a/apps/admin-x-framework/src/api/newsletters.ts b/apps/admin-x-framework/src/api/newsletters.ts index a7290e5409..5f9fdf55d5 100644 --- a/apps/admin-x-framework/src/api/newsletters.ts +++ b/apps/admin-x-framework/src/api/newsletters.ts @@ -61,7 +61,7 @@ export const useBrowseNewsletters = createInfiniteQuery { const {pages} = originalData as InfiniteData; const newsletters = pages.flatMap(page => page.newsletters); - const meta = pages.at(-1)!.meta; + const meta = pages[pages.length - 1].meta; return { newsletters: newsletters, diff --git a/apps/admin-x-framework/src/api/tiers.ts b/apps/admin-x-framework/src/api/tiers.ts index 6ac9b67566..1813846caf 100644 --- a/apps/admin-x-framework/src/api/tiers.ts +++ b/apps/admin-x-framework/src/api/tiers.ts @@ -41,7 +41,7 @@ export const useBrowseTiers = createInfiniteQuery { const {pages} = originalData as InfiniteData; const tiers = pages.flatMap(page => page.tiers); - const meta = pages.at(-1)!.meta; + const meta = pages[pages.length - 1].meta; return { tiers, diff --git a/apps/admin-x-framework/src/api/users.ts b/apps/admin-x-framework/src/api/users.ts index 9df81ed45f..b5c8b855a4 100644 --- a/apps/admin-x-framework/src/api/users.ts +++ b/apps/admin-x-framework/src/api/users.ts @@ -76,7 +76,7 @@ export const useBrowseUsers = createInfiniteQuery { const {pages} = originalData as InfiniteData; const users = pages.flatMap(page => page.users); - const meta = pages.at(-1)!.meta; + const meta = pages[pages.length - 1].meta; return { users: users, diff --git a/apps/admin-x-framework/src/utils/api/updateQueries.ts b/apps/admin-x-framework/src/utils/api/updateQueries.ts index bc2890c723..a797d2fd83 100644 --- a/apps/admin-x-framework/src/utils/api/updateQueries.ts +++ b/apps/admin-x-framework/src/utils/api/updateQueries.ts @@ -10,7 +10,7 @@ export const insertToQueryCache = (field: string, recordsToInsert? if (typeof currentData === 'object' && 'pages' in currentData) { const {pages} = currentData as InfiniteData; - const lastPage = pages.at(-1)!; + const lastPage = pages[pages.length - 1]; return { ...currentData, pages: pages.slice(0, -1).concat({