convex-helpers 0.1.95 → 0.1.96
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/browser.test.ts +1 -1
- package/package.json +1 -1
- package/react.d.ts.map +1 -1
- package/react.js +20 -22
- package/react.ts +21 -21
package/browser.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
2
|
import type { FunctionReference } from "convex/server";
|
|
3
3
|
import type { ConvexClient } from "convex/browser";
|
|
4
|
-
import { withArgs } from "./browser";
|
|
4
|
+
import { withArgs } from "./browser.js";
|
|
5
5
|
|
|
6
6
|
describe("withArgs", () => {
|
|
7
7
|
let mockClient: ConvexClient;
|
package/package.json
CHANGED
package/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,UAAU,EAEX,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAInB,MAAM,eAAe,CAAC;AAOvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,QAAQ,GA0CM,KAAK,SAAS,iBAAiB,CAAC,OAAO,CAAC,SACxD,KAAK,gBACE,sBAAsB,CAAC,KAAK,CAAC,KAEzC;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChC,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;CAChB,GACD;IACE,MAAM,EAAE,SAAS,CAAC;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,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAChC,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;CAChB,GACD;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;CAChB,GACD;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,KAAK,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,IAAI,CAAC;CACf,CAsDN;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,uBAAuB,EACrE,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,MAAM,EACxC,OAAO,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GACnC,2BAA2B,CAAC,KAAK,CAAC,CA8OpC"}
|
package/react.js
CHANGED
|
@@ -89,7 +89,6 @@ export function makeUseQueryWithStatus(useQueriesHook) {
|
|
|
89
89
|
args,
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
92
|
}, [getFunctionName(query), JSON.stringify(args)]);
|
|
94
93
|
const result = useQueriesHook(queries);
|
|
95
94
|
if (args === "skip") {
|
|
@@ -191,9 +190,7 @@ export function usePaginatedQuery(query, args, options) {
|
|
|
191
190
|
// ESLint doesn't like that we're stringifying the args. We do this because
|
|
192
191
|
// we want to avoid rerendering if the args are a different
|
|
193
192
|
// object that serializes to the same result.
|
|
194
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
195
193
|
}, [
|
|
196
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
197
194
|
JSON.stringify(convexToJson(argsObject)),
|
|
198
195
|
queryName,
|
|
199
196
|
options.initialNumItems,
|
|
@@ -274,25 +271,26 @@ export function usePaginatedQuery(query, args, options) {
|
|
|
274
271
|
logger,
|
|
275
272
|
]);
|
|
276
273
|
const statusObject = useMemo(() => {
|
|
277
|
-
if (maybeLastResult === undefined) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
274
|
+
if (maybeLastResult === undefined && currState.nextPageKey === 1) {
|
|
275
|
+
return {
|
|
276
|
+
status: "LoadingFirstPage",
|
|
277
|
+
isLoading: true,
|
|
278
|
+
loadMore: (_numItems) => {
|
|
279
|
+
// Intentional noop.
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
else if (maybeLastResult === undefined ||
|
|
284
|
+
// The last page (which isn't the first page) is splitting, which is how
|
|
285
|
+
// we model loading more in this helper
|
|
286
|
+
currState.ongoingSplits[currState.nextPageKey - 1] !== undefined) {
|
|
287
|
+
return {
|
|
288
|
+
status: "LoadingMore",
|
|
289
|
+
isLoading: true,
|
|
290
|
+
loadMore: (_numItems) => {
|
|
291
|
+
// Intentional noop.
|
|
292
|
+
},
|
|
293
|
+
};
|
|
296
294
|
}
|
|
297
295
|
if (maybeLastResult.isDone) {
|
|
298
296
|
return {
|
package/react.ts
CHANGED
|
@@ -138,7 +138,6 @@ export function makeUseQueryWithStatus(useQueriesHook: typeof useQueries) {
|
|
|
138
138
|
args,
|
|
139
139
|
},
|
|
140
140
|
};
|
|
141
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
141
|
}, [getFunctionName(query), JSON.stringify(args)]);
|
|
143
142
|
const result = useQueriesHook(queries);
|
|
144
143
|
if (args === "skip") {
|
|
@@ -249,9 +248,7 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
|
|
|
249
248
|
// ESLint doesn't like that we're stringifying the args. We do this because
|
|
250
249
|
// we want to avoid rerendering if the args are a different
|
|
251
250
|
// object that serializes to the same result.
|
|
252
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
253
251
|
}, [
|
|
254
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
255
252
|
JSON.stringify(convexToJson(argsObject as Value)),
|
|
256
253
|
queryName,
|
|
257
254
|
options.initialNumItems,
|
|
@@ -358,24 +355,27 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
|
|
|
358
355
|
]);
|
|
359
356
|
|
|
360
357
|
const statusObject = useMemo(() => {
|
|
361
|
-
if (maybeLastResult === undefined) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
358
|
+
if (maybeLastResult === undefined && currState.nextPageKey === 1) {
|
|
359
|
+
return {
|
|
360
|
+
status: "LoadingFirstPage",
|
|
361
|
+
isLoading: true,
|
|
362
|
+
loadMore: (_numItems: number) => {
|
|
363
|
+
// Intentional noop.
|
|
364
|
+
},
|
|
365
|
+
} as const;
|
|
366
|
+
} else if (
|
|
367
|
+
maybeLastResult === undefined ||
|
|
368
|
+
// The last page (which isn't the first page) is splitting, which is how
|
|
369
|
+
// we model loading more in this helper
|
|
370
|
+
currState.ongoingSplits[currState.nextPageKey - 1] !== undefined
|
|
371
|
+
) {
|
|
372
|
+
return {
|
|
373
|
+
status: "LoadingMore",
|
|
374
|
+
isLoading: true,
|
|
375
|
+
loadMore: (_numItems: number) => {
|
|
376
|
+
// Intentional noop.
|
|
377
|
+
},
|
|
378
|
+
} as const;
|
|
379
379
|
}
|
|
380
380
|
if (maybeLastResult.isDone) {
|
|
381
381
|
return {
|