Skip to content

Commit 3b2f2c7

Browse files
committed
initial code fix
1 parent 67c5a90 commit 3b2f2c7

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/firestore/src/core/sync_engine_impl.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,13 @@ async function applyDocChanges(
10811081

10821082
const targetChange =
10831083
remoteEvent && remoteEvent.targetChanges.get(queryView.targetId);
1084+
const isPendingForRequeryResult =
1085+
remoteEvent && remoteEvent.targetMismatches.get(queryView.targetId) != null;
10841086
const viewChange = queryView.view.applyChanges(
10851087
viewDocChanges,
10861088
/* updateLimboDocuments= */ syncEngineImpl.isPrimaryClient,
1087-
targetChange
1089+
targetChange,
1090+
isPendingForRequeryResult
10881091
);
10891092
updateTrackedLimbos(
10901093
syncEngineImpl,

packages/firestore/src/core/view.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ export class View {
273273
* @param docChanges - The set of changes to make to the view's docs.
274274
* @param updateLimboDocuments - Whether to update limbo documents based on
275275
* this change.
276+
* @param isPendingForRequeryResult - Whether the target is pending to run a full
277+
* re-query due to existence filter mismatch.
276278
* @param targetChange - A target change to apply for computing limbo docs and
277279
* sync state.
278280
* @returns A new ViewChange with the given docs, changes, and sync state.
@@ -281,7 +283,8 @@ export class View {
281283
applyChanges(
282284
docChanges: ViewDocumentChanges,
283285
updateLimboDocuments: boolean,
284-
targetChange?: TargetChange
286+
targetChange?: TargetChange,
287+
isPendingForRequeryResult: boolean = false,
285288
): ViewChange {
286289
debugAssert(
287290
!docChanges.needsRefill,
@@ -300,10 +303,16 @@ export class View {
300303
});
301304

302305
this.applyTargetChange(targetChange);
303-
const limboChanges = updateLimboDocuments
306+
const limboChanges = !isPendingForRequeryResult && updateLimboDocuments
304307
? this.updateLimboDocuments()
305308
: [];
306-
const synced = this.limboDocuments.size === 0 && this.current;
309+
310+
// We are at synced state if there is no limbo docs are waiting to be resolved, view is current
311+
// with the backend, and the query is not pending for full re-query result due to existence
312+
// filter mismatch.
313+
const synced =
314+
this.limboDocuments.size === 0 && this.current && !isPendingForRequeryResult;
315+
307316
const newSyncState = synced ? SyncState.Synced : SyncState.Local;
308317
const syncStateChanged = newSyncState !== this.syncState;
309318
this.syncState = newSyncState;

0 commit comments

Comments
 (0)