diff --git a/package-lock.json b/package-lock.json index 9717abe98476..da7609980b83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -118,7 +118,7 @@ "react-native-localize": "^3.5.4", "react-native-nitro-modules": "0.29.4", "react-native-nitro-sqlite": "9.2.0", - "react-native-onyx": "3.0.15", + "react-native-onyx": "3.0.23", "react-native-pager-view": "6.9.1", "react-native-pdf": "7.0.2", "react-native-performance": "^6.0.0", @@ -35587,9 +35587,9 @@ } }, "node_modules/react-native-onyx": { - "version": "3.0.15", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-3.0.15.tgz", - "integrity": "sha512-3luv5Fqt1mquXjZ7HEdgOCG0KkCmV5UVL595oUDTPsILkI4hrjHIVelfybKhGi/ldWRO4jomgsDWRkDkQQdgoA==", + "version": "3.0.23", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-3.0.23.tgz", + "integrity": "sha512-CFUr24AzJyMXZoFxJ7pMivUh+WkkmZA5KbQgVer4qRD68zsoxgC8bGJ6sB0j3VFvxhjkiZDUVtta0lu//gh/SQ==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", @@ -35601,7 +35601,7 @@ "underscore": "^1.13.6" }, "engines": { - "node": ">=20.19.3", + "node": ">=20.19.5", "npm": ">=10.8.2" }, "peerDependencies": { diff --git a/package.json b/package.json index 976cd587bc22..8258181fcc39 100644 --- a/package.json +++ b/package.json @@ -189,7 +189,7 @@ "react-native-localize": "^3.5.4", "react-native-nitro-modules": "0.29.4", "react-native-nitro-sqlite": "9.2.0", - "react-native-onyx": "3.0.15", + "react-native-onyx": "3.0.23", "react-native-pager-view": "6.9.1", "react-native-pdf": "7.0.2", "react-native-performance": "^6.0.0", diff --git a/src/libs/Middleware/Pagination.ts b/src/libs/Middleware/Pagination.ts index 5162356f65f8..acb4850a0022 100644 --- a/src/libs/Middleware/Pagination.ts +++ b/src/libs/Middleware/Pagination.ts @@ -12,6 +12,9 @@ import type Middleware from './types'; type PagedResource = OnyxValues[TResourceKey] extends Record ? TResource : never; +// Simplified type for paginated resource collections to avoid complex union type errors +type PaginatedResourceCollection = Record; + type PaginationCommonConfig = { resourceCollectionKey: TResourceKey; pageCollectionKey: TPageKey; @@ -95,7 +98,8 @@ const Pagination: Middleware = (requestResponse, request) => { const pageKey = `${pageCollectionKey}${resourceID}` as const; // Create a new page based on the response - const pageItems = (response.onyxData.find((data) => data.key === resourceKey)?.value ?? {}) as OnyxValues[typeof resourceCollectionKey]; + const pageData = response.onyxData.find((data) => data.key === resourceKey) as {value?: PaginatedResourceCollection} | undefined; + const pageItems: PaginatedResourceCollection = pageData?.value ?? {}; const sortedPageItems = sortItems(pageItems, resourceID); if (sortedPageItems.length === 0) { // Must have at least 1 action to create a page. @@ -113,7 +117,7 @@ const Pagination: Middleware = (requestResponse, request) => { } const resourceCollections = resources.get(resourceCollectionKey) ?? {}; - const existingItems = resourceCollections[resourceKey] ?? {}; + const existingItems = (resourceCollections[resourceKey] ?? {}) as PaginatedResourceCollection; const allItems = fastMerge(existingItems, pageItems, true); const sortedAllItems = sortItems(allItems, resourceID);