Skip to content

Commit d937e24

Browse files
committed
Fix isLoading stuck true with coalesced requests in reactive frameworks
When multiple reactive getters (e.g., in Alpine.js) call .it() for the same item during a single reactive cycle, the requests are correctly coalesced but isLoading can remain true even after data is fetched. Root cause: finalizeItemMeta only set isLoading=false when query IDs matched or activeQueryId was null. With coalesced requests, especially silent fetches, the activeQueryId matching logic could fail. Solution: Explicitly check if ref.data exists. If data is present, the item is definitively not loading, regardless of query ID matching. This handles the coalescing edge case while preserving all existing behavior. This fix ensures proper loading states for: - Alpine.js reactive computed properties - React hooks with multiple consumers - Vue computed properties - Svelte reactive declarations Fixes: https://github.com/YidiDev/verity/issues (see BUG.md) Version: 1.0.7 → 1.0.8
1 parent 1ed6a16 commit d937e24

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "verity-dl",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "A framework agnostic data layer built to handle the communication layer between the server and the client seamlessly and keep the ui state always up to date with the source of truth",
55
"main": "verity/shared/static/lib/core.js",
66
"module": "verity/shared/static/lib/core.js",

verity/shared/static/lib/core.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,11 @@ function finalizeItemMeta(ref, canonicalLevel, qid, overrides = {}, { force = fa
10531053
};
10541054

10551055
if (!Object.prototype.hasOwnProperty.call(overrides, "isLoading")) {
1056-
if (matchedActiveQuery || next.activeQueryId == null) {
1056+
// If we have data, we're definitely not loading
1057+
// This handles cases where coalesced requests may have mismatched query IDs
1058+
if (ref.data != null) {
1059+
next.isLoading = false;
1060+
} else if (matchedActiveQuery || next.activeQueryId == null) {
10571061
next.isLoading = false;
10581062
}
10591063
}

0 commit comments

Comments
 (0)