Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions src/libs/Middleware/Pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

type PagedResource<TResourceKey extends OnyxCollectionKey> = OnyxValues[TResourceKey] extends Record<string, infer TResource> ? TResource : never;

// Simplified type for paginated resource collections to avoid complex union type errors
type PaginatedResourceCollection = Record<string, unknown>;

type PaginationCommonConfig<TResourceKey extends OnyxCollectionKey = OnyxCollectionKey, TPageKey extends OnyxPagesKey = OnyxPagesKey> = {
resourceCollectionKey: TResourceKey;
pageCollectionKey: TPageKey;
Expand Down Expand Up @@ -47,14 +50,14 @@
paginationConfigs.set(initialCommand, {...config, type: 'initial'} as unknown as PaginationConfigMapValue);
paginationConfigs.set(previousCommand, {...config, type: 'previous'} as unknown as PaginationConfigMapValue);
paginationConfigs.set(nextCommand, {...config, type: 'next'} as unknown as PaginationConfigMapValue);
Onyx.connect<OnyxCollectionKey>({

Check warning on line 53 in src/libs/Middleware/Pagination.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 53 in src/libs/Middleware/Pagination.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: config.resourceCollectionKey,
waitForCollectionCallback: true,
callback: (data) => {
resources.set(config.resourceCollectionKey, data);
},
});
Onyx.connect<OnyxPagesKey>({

Check warning on line 60 in src/libs/Middleware/Pagination.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 60 in src/libs/Middleware/Pagination.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: config.pageCollectionKey,
waitForCollectionCallback: true,
callback: (data) => {
Expand Down Expand Up @@ -95,7 +98,8 @@
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.
Expand All @@ -113,7 +117,7 @@
}

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);

Expand Down
Loading