@statezero/core 0.1.22 → 0.1.24
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.
|
@@ -134,7 +134,7 @@ export class QuerysetStore {
|
|
|
134
134
|
let result;
|
|
135
135
|
if (this.getRootStore && typeof this.getRootStore === "function" && !this.isTemp) {
|
|
136
136
|
const { isRoot, rootStore } = this.getRootStore(this.queryset);
|
|
137
|
-
if (!isRoot && rootStore) {
|
|
137
|
+
if (!isRoot && rootStore && rootStore.lastSync) {
|
|
138
138
|
result = this.renderFromRoot(optimistic, rootStore);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -203,7 +203,7 @@ export class QuerysetStore {
|
|
|
203
203
|
// Check if we're delegating to a root store
|
|
204
204
|
if (this.getRootStore && typeof this.getRootStore === "function" && !this.isTemp) {
|
|
205
205
|
const { isRoot, rootStore } = this.getRootStore(this.queryset);
|
|
206
|
-
if (!isRoot && rootStore) {
|
|
206
|
+
if (!isRoot && rootStore && rootStore.lastSync) {
|
|
207
207
|
// We're delegating to a root store - don't sync, just mark as needing sync
|
|
208
208
|
console.log(`[${id}] Delegating to root store, marking sync needed.`);
|
|
209
209
|
this.needsSync = true;
|
package/dist/syncEngine/sync.js
CHANGED
|
@@ -80,7 +80,7 @@ export class SyncManager {
|
|
|
80
80
|
this.followedModels.set(registry, models);
|
|
81
81
|
if (models.has(modelClass))
|
|
82
82
|
return;
|
|
83
|
-
const alreadyFollowed = [...this.followedModels.values()].some(set => set.has(modelClass));
|
|
83
|
+
const alreadyFollowed = [...this.followedModels.values()].some((set) => set.has(modelClass));
|
|
84
84
|
models.add(modelClass);
|
|
85
85
|
if (!alreadyFollowed) {
|
|
86
86
|
getEventReceiver(modelClass.configKey)?.subscribe(modelClass.modelName, this.handleEvent);
|
|
@@ -91,7 +91,7 @@ export class SyncManager {
|
|
|
91
91
|
if (!models)
|
|
92
92
|
return;
|
|
93
93
|
models.delete(modelClass);
|
|
94
|
-
const stillFollowed = [...this.followedModels.values()].some(set => set.has(modelClass));
|
|
94
|
+
const stillFollowed = [...this.followedModels.values()].some((set) => set.has(modelClass));
|
|
95
95
|
if (!stillFollowed) {
|
|
96
96
|
getEventReceiver(modelClass.configKey)?.unsubscribe(modelClass.modelName, this.handleEvent);
|
|
97
97
|
}
|
|
@@ -104,10 +104,10 @@ export class SyncManager {
|
|
|
104
104
|
this.registries.delete(registry.constructor.name);
|
|
105
105
|
}
|
|
106
106
|
isQuerysetFollowed(queryset) {
|
|
107
|
+
const activeSemanticKeys = new Set([...this.followedQuerysets].map((qs) => qs.semanticKey));
|
|
107
108
|
let current = queryset;
|
|
108
|
-
// All followed querysets and their descendents get updated
|
|
109
109
|
while (current) {
|
|
110
|
-
if (
|
|
110
|
+
if (activeSemanticKeys.has(current.semanticKey)) {
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
113
|
current = current.__parent;
|
|
@@ -127,7 +127,7 @@ export class SyncManager {
|
|
|
127
127
|
const followingQuerysets = registry.followingQuerysets.get(semanticKey);
|
|
128
128
|
if (followingQuerysets) {
|
|
129
129
|
// Use some() to break early when we find a match
|
|
130
|
-
const shouldSync = [...followingQuerysets].some(queryset => {
|
|
130
|
+
const shouldSync = [...followingQuerysets].some((queryset) => {
|
|
131
131
|
return this.isQuerysetFollowed(queryset);
|
|
132
132
|
});
|
|
133
133
|
if (shouldSync) {
|
package/package.json
CHANGED