Skip to content

Commit a3eadb4

Browse files
committed
add changeset, rename parameter
1 parent f4d0654 commit a3eadb4

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.changeset/warm-oranges-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/firestore': patch
3+
---
4+
5+
Fix metadata `fromCache` default to `true` issue when listen to cache in multi-tabs.

packages/firestore/src/core/sync_engine_impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ async function allocateTargetAndMaybeListen(
356356
const status: QueryTargetState =
357357
syncEngineImpl.sharedClientState.addLocalQueryTarget(
358358
targetId,
359-
shouldListenToRemote
359+
/* addToActiveTargetIds= */ shouldListenToRemote
360360
);
361361

362362
let viewSnapshot;

packages/firestore/src/local/shared_client_state.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export interface SharedClientState {
106106
*/
107107
addLocalQueryTarget(
108108
targetId: TargetId,
109-
addActiveTargetId?: boolean
109+
addToActiveTargetIds?: boolean
110110
): QueryTargetState;
111111

112112
/** Removes the Query Target ID association from the local client. */
@@ -660,7 +660,7 @@ export class WebStorageSharedClientState implements SharedClientState {
660660

661661
addLocalQueryTarget(
662662
targetId: TargetId,
663-
addActiveTargetId: boolean = true
663+
addToActiveTargetIds: boolean = true
664664
): QueryTargetState {
665665
let queryState: QueryTargetState = 'not-current';
666666

@@ -682,11 +682,13 @@ export class WebStorageSharedClientState implements SharedClientState {
682682
}
683683
}
684684

685-
if (addActiveTargetId) {
685+
// If the query is listening to cache only, the target ID should not be registered the with
686+
// local Firestore client as active watch target.
687+
if (addToActiveTargetIds) {
686688
this.localClientState.addQueryTarget(targetId);
687-
this.persistClientState();
688689
}
689690

691+
this.persistClientState();
690692
return queryState;
691693
}
692694

@@ -1120,9 +1122,9 @@ export class MemorySharedClientState implements SharedClientState {
11201122

11211123
addLocalQueryTarget(
11221124
targetId: TargetId,
1123-
addActiveTargetId: boolean = true
1125+
addToActiveTargetIds: boolean = true
11241126
): QueryTargetState {
1125-
if (addActiveTargetId) {
1127+
if (addToActiveTargetIds) {
11261128
this.localState.addQueryTarget(targetId);
11271129
}
11281130
return this.queryState[targetId] || 'not-current';

0 commit comments

Comments
 (0)