Skip to content

Commit 20a094f

Browse files
Clean up isPrimary (#3058)
1 parent 2261bcd commit 20a094f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/firestore/src/core/sync_engine.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ export class MultiTabSyncEngine extends SyncEngine
921921
// The primary state is set to `true` or `false` immediately after Firestore
922922
// startup. In the interim, a client should only be considered primary if
923923
// `isPrimary` is true.
924-
private isPrimary: undefined | boolean = undefined;
924+
private _isPrimaryClient: undefined | boolean = undefined;
925925

926926
constructor(
927927
protected localStore: MultiTabLocalStore,
@@ -940,7 +940,7 @@ export class MultiTabSyncEngine extends SyncEngine
940940
}
941941

942942
get isPrimaryClient(): boolean {
943-
return this.isPrimary === true;
943+
return this._isPrimaryClient === true;
944944
}
945945

946946
enableNetwork(): Promise<void> {
@@ -967,7 +967,7 @@ export class MultiTabSyncEngine extends SyncEngine
967967
const viewSnapshot = queryView.view.synchronizeWithPersistedState(
968968
queryResult
969969
);
970-
if (this.isPrimary) {
970+
if (this._isPrimaryClient) {
971971
this.updateTrackedLimbos(queryView.targetId, viewSnapshot.limboChanges);
972972
}
973973
return viewSnapshot;
@@ -1034,7 +1034,7 @@ export class MultiTabSyncEngine extends SyncEngine
10341034
}
10351035

10361036
async applyPrimaryState(isPrimary: boolean): Promise<void> {
1037-
if (isPrimary === true && this.isPrimary !== true) {
1037+
if (isPrimary === true && this._isPrimaryClient !== true) {
10381038
// Secondary tabs only maintain Views for their local listeners and the
10391039
// Views internal state may not be 100% populated (in particular
10401040
// secondary tabs don't track syncedDocuments, the set of documents the
@@ -1046,12 +1046,12 @@ export class MultiTabSyncEngine extends SyncEngine
10461046
activeTargets.toArray(),
10471047
/*transitionToPrimary=*/ true
10481048
);
1049-
this.isPrimary = true;
1049+
this._isPrimaryClient = true;
10501050
await this.remoteStore.applyPrimaryState(true);
10511051
for (const targetData of activeQueries) {
10521052
this.remoteStore.listen(targetData);
10531053
}
1054-
} else if (isPrimary === false && this.isPrimary !== false) {
1054+
} else if (isPrimary === false && this._isPrimaryClient !== false) {
10551055
const activeTargets: TargetId[] = [];
10561056

10571057
let p = Promise.resolve();
@@ -1076,7 +1076,7 @@ export class MultiTabSyncEngine extends SyncEngine
10761076
/*transitionToPrimary=*/ false
10771077
);
10781078
this.resetLimboDocuments();
1079-
this.isPrimary = false;
1079+
this._isPrimaryClient = false;
10801080
await this.remoteStore.applyPrimaryState(false);
10811081
}
10821082
}
@@ -1191,7 +1191,7 @@ export class MultiTabSyncEngine extends SyncEngine
11911191
state: QueryTargetState,
11921192
error?: FirestoreError
11931193
): Promise<void> {
1194-
if (this.isPrimary) {
1194+
if (this._isPrimaryClient) {
11951195
// If we receive a target state notification via WebStorage, we are
11961196
// either already secondary or another tab has taken the primary lease.
11971197
logDebug(LOG_TAG, 'Ignoring unexpected query state notification.');
@@ -1231,7 +1231,7 @@ export class MultiTabSyncEngine extends SyncEngine
12311231
added: TargetId[],
12321232
removed: TargetId[]
12331233
): Promise<void> {
1234-
if (!this.isPrimary) {
1234+
if (!this._isPrimaryClient) {
12351235
return;
12361236
}
12371237

0 commit comments

Comments
 (0)