@adventurelabs/scout-core 1.4.28 → 1.4.31

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.
@@ -457,13 +457,11 @@ export const useInfiniteFeedByHerd = (herdId, options) => {
457
457
  ? currentQuery.data.items
458
458
  : [];
459
459
  const limit = options.limit || 20;
460
- // Defer lastResult to next tick so consumer's IntersectionObserver is recreated
461
- // after hasMore is true and its callback can fire (sentinel may already be in view).
462
460
  const nextResult = {
463
461
  hasMore: currentQuery.data.hasMore ?? false,
464
462
  nextCursor: currentQuery.data.nextCursor ?? null,
465
463
  };
466
- queueMicrotask(() => setLastResult(nextResult));
464
+ setLastResult(nextResult);
467
465
  setPages((prev) => {
468
466
  const existingPage = prev.find((p) => feedCursorEq(p.cursor, currentCursor));
469
467
  if (!existingPage) {
@@ -477,6 +475,11 @@ export const useInfiniteFeedByHerd = (herdId, options) => {
477
475
  }
478
476
  return prev;
479
477
  });
478
+ // Request next page when this response has more (avoids relying on consumer's
479
+ // IntersectionObserver when sentinel is already in view and callback doesn't re-fire).
480
+ if (nextResult.hasMore && nextResult.nextCursor != null) {
481
+ setCurrentCursor(nextResult.nextCursor);
482
+ }
480
483
  }, [currentQuery.data, currentQuery.isLoading, currentCursor, pages.length, options.limit]);
481
484
  const loadMore = useCallback(() => {
482
485
  if (lastResult?.hasMore &&
@@ -555,7 +558,7 @@ export const useInfiniteFeedByDevice = (deviceId, options) => {
555
558
  hasMore: currentQuery.data?.hasMore ?? false,
556
559
  nextCursor: currentQuery.data?.nextCursor ?? null,
557
560
  };
558
- queueMicrotask(() => setLastResult(nextResult));
561
+ setLastResult(nextResult);
559
562
  setPages((prev) => {
560
563
  const existingPage = prev.find((p) => feedCursorEq(p.cursor, currentCursor));
561
564
  if (!existingPage) {
@@ -573,6 +576,9 @@ export const useInfiniteFeedByDevice = (deviceId, options) => {
573
576
  }
574
577
  return prev;
575
578
  });
579
+ if (nextResult.hasMore && nextResult.nextCursor != null) {
580
+ setCurrentCursor(nextResult.nextCursor);
581
+ }
576
582
  }, [currentQuery.data, currentQuery.isLoading, currentCursor, pages.length, options.limit]);
577
583
  const loadMore = useCallback(() => {
578
584
  if (lastResult?.hasMore &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adventurelabs/scout-core",
3
- "version": "1.4.28",
3
+ "version": "1.4.31",
4
4
  "description": "Core utilities and helpers for Adventure Labs Scout applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",