@codeleap/query 5.8.4 → 5.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/query",
3
- "version": "5.8.4",
3
+ "version": "5.8.5",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -9,15 +9,15 @@
9
9
  "directory": "packages/query"
10
10
  },
11
11
  "devDependencies": {
12
- "@codeleap/config": "5.8.4",
13
- "@codeleap/types": "5.8.4",
12
+ "@codeleap/config": "5.8.5",
13
+ "@codeleap/types": "5.8.5",
14
14
  "ts-node-dev": "1.1.8"
15
15
  },
16
16
  "scripts": {
17
17
  "build": "echo 'No build needed'"
18
18
  },
19
19
  "peerDependencies": {
20
- "@codeleap/types": "5.8.4",
20
+ "@codeleap/types": "5.8.5",
21
21
  "typescript": "5.5.2",
22
22
  "@tanstack/react-query": "5.89.0"
23
23
  },
package/package.json.bak CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/query",
3
- "version": "5.8.4",
3
+ "version": "5.8.5",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -46,7 +46,7 @@ export class Mutations<T extends QueryItem, F> {
46
46
  for (const [queryKey, itemPosition] of position) {
47
47
  const currentData = this.queryClient.getQueryData<InfiniteData<ListPaginationResponse<T>, PageParam>>(queryKey)
48
48
 
49
- const updatedPages = [...currentData.pages]
49
+ const updatedPages = [...(currentData?.pages || [])]
50
50
 
51
51
  if (itemPosition.pageIndex < updatedPages.length) {
52
52
  const targetPage = [...updatedPages[itemPosition.pageIndex]]
@@ -224,11 +224,11 @@ export class Mutations<T extends QueryItem, F> {
224
224
  const oldData = query.state?.data
225
225
  const queryKey = query?.queryKey
226
226
 
227
- if (!oldData) continue
227
+ if (!oldData?.pages || !Array.isArray(oldData?.pages)) continue
228
228
 
229
229
  let hasChanges = false
230
230
 
231
- const updatedPages = oldData.pages.map(page => {
231
+ const updatedPages = (oldData?.pages ?? [])?.filter(Array.isArray)?.map(page => {
232
232
  let pageChanged = false
233
233
 
234
234
  const updatedPage = page.map((item) => {