@@ -918,10 +918,7 @@ export class SyncEngine implements RemoteSyncer {
918
918
// PORTING NOTE: Web only
919
919
export class MultiTabSyncEngine extends SyncEngine
920
920
implements SharedClientStateSyncer {
921
- // The primary state is set to `true` or `false` immediately after Firestore
922
- // startup. In the interim, a client should only be considered primary if
923
- // `isPrimary` is true.
924
- private isPrimary : undefined | boolean = undefined ;
921
+ isPrimaryClient = false ;
925
922
926
923
constructor (
927
924
protected localStore : MultiTabLocalStore ,
@@ -939,10 +936,6 @@ export class MultiTabSyncEngine extends SyncEngine
939
936
) ;
940
937
}
941
938
942
- get isPrimaryClient ( ) : boolean {
943
- return this . isPrimary === true ;
944
- }
945
-
946
939
enableNetwork ( ) : Promise < void > {
947
940
this . localStore . setNetworkEnabled ( true ) ;
948
941
return super . enableNetwork ( ) ;
@@ -967,7 +960,7 @@ export class MultiTabSyncEngine extends SyncEngine
967
960
const viewSnapshot = queryView . view . synchronizeWithPersistedState (
968
961
queryResult
969
962
) ;
970
- if ( this . isPrimary ) {
963
+ if ( this . isPrimaryClient ) {
971
964
this . updateTrackedLimbos ( queryView . targetId , viewSnapshot . limboChanges ) ;
972
965
}
973
966
return viewSnapshot ;
@@ -1034,7 +1027,7 @@ export class MultiTabSyncEngine extends SyncEngine
1034
1027
}
1035
1028
1036
1029
async applyPrimaryState ( isPrimary : boolean ) : Promise < void > {
1037
- if ( isPrimary === true && this . isPrimary !== true ) {
1030
+ if ( isPrimary === true && this . isPrimaryClient !== true ) {
1038
1031
// Secondary tabs only maintain Views for their local listeners and the
1039
1032
// Views internal state may not be 100% populated (in particular
1040
1033
// secondary tabs don't track syncedDocuments, the set of documents the
@@ -1046,12 +1039,12 @@ export class MultiTabSyncEngine extends SyncEngine
1046
1039
activeTargets . toArray ( ) ,
1047
1040
/*transitionToPrimary=*/ true
1048
1041
) ;
1049
- this . isPrimary = true ;
1042
+ this . isPrimaryClient = true ;
1050
1043
await this . remoteStore . applyPrimaryState ( true ) ;
1051
1044
for ( const targetData of activeQueries ) {
1052
1045
this . remoteStore . listen ( targetData ) ;
1053
1046
}
1054
- } else if ( isPrimary === false && this . isPrimary !== false ) {
1047
+ } else if ( isPrimary === false && this . isPrimaryClient !== false ) {
1055
1048
const activeTargets : TargetId [ ] = [ ] ;
1056
1049
1057
1050
let p = Promise . resolve ( ) ;
@@ -1076,7 +1069,7 @@ export class MultiTabSyncEngine extends SyncEngine
1076
1069
/*transitionToPrimary=*/ false
1077
1070
) ;
1078
1071
this . resetLimboDocuments ( ) ;
1079
- this . isPrimary = false ;
1072
+ this . isPrimaryClient = false ;
1080
1073
await this . remoteStore . applyPrimaryState ( false ) ;
1081
1074
}
1082
1075
}
@@ -1191,7 +1184,7 @@ export class MultiTabSyncEngine extends SyncEngine
1191
1184
state : QueryTargetState ,
1192
1185
error ?: FirestoreError
1193
1186
) : Promise < void > {
1194
- if ( this . isPrimary ) {
1187
+ if ( this . isPrimaryClient ) {
1195
1188
// If we receive a target state notification via WebStorage, we are
1196
1189
// either already secondary or another tab has taken the primary lease.
1197
1190
logDebug ( LOG_TAG , 'Ignoring unexpected query state notification.' ) ;
@@ -1231,7 +1224,7 @@ export class MultiTabSyncEngine extends SyncEngine
1231
1224
added : TargetId [ ] ,
1232
1225
removed : TargetId [ ]
1233
1226
) : Promise < void > {
1234
- if ( ! this . isPrimary ) {
1227
+ if ( ! this . isPrimaryClient ) {
1235
1228
return ;
1236
1229
}
1237
1230
0 commit comments