@@ -526,7 +526,6 @@ export class WebStorageSharedClientState implements SharedClientState {
526
526
private readonly sequenceNumberKey : string ;
527
527
private readonly activeClients : { [ key : string ] : ClientState } = { } ;
528
528
private readonly storageListener = this . handleWebStorageEvent . bind ( this ) ;
529
- private readonly escapedPersistenceKey : string ;
530
529
private readonly onlineStateKey : string ;
531
530
private readonly clientStateKeyRe : RegExp ;
532
531
private readonly mutationBatchKeyRe : RegExp ;
@@ -543,7 +542,7 @@ export class WebStorageSharedClientState implements SharedClientState {
543
542
constructor (
544
543
private readonly queue : AsyncQueue ,
545
544
private readonly platform : Platform ,
546
- persistenceKey : string ,
545
+ private readonly persistenceKey : string ,
547
546
private readonly localClientId : ClientId ,
548
547
initialUser : User
549
548
) {
@@ -555,7 +554,7 @@ export class WebStorageSharedClientState implements SharedClientState {
555
554
}
556
555
// Escape the special characters mentioned here:
557
556
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
558
- this . escapedPersistenceKey = persistenceKey . replace (
557
+ const escapedPersistenceKey = persistenceKey . replace (
559
558
/ [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g,
560
559
'\\$&'
561
560
) ;
@@ -565,26 +564,20 @@ export class WebStorageSharedClientState implements SharedClientState {
565
564
this . localClientStorageKey = this . toWebStorageClientStateKey (
566
565
this . localClientId
567
566
) ;
568
- this . sequenceNumberKey = `${ SEQUENCE_NUMBER_KEY_PREFIX } _${
569
- this . escapedPersistenceKey
570
- } `;
567
+ this . sequenceNumberKey = `${ SEQUENCE_NUMBER_KEY_PREFIX } _${ persistenceKey } ` ;
571
568
this . activeClients [ this . localClientId ] = new LocalClientState ( ) ;
572
569
573
570
this . clientStateKeyRe = new RegExp (
574
- `^${ CLIENT_STATE_KEY_PREFIX } _${ this . escapedPersistenceKey } _([^_]*)$`
571
+ `^${ CLIENT_STATE_KEY_PREFIX } _${ escapedPersistenceKey } _([^_]*)$`
575
572
) ;
576
573
this . mutationBatchKeyRe = new RegExp (
577
- `^${ MUTATION_BATCH_KEY_PREFIX } _${
578
- this . escapedPersistenceKey
579
- } _(\\d+)(?:_(.*))?$`
574
+ `^${ MUTATION_BATCH_KEY_PREFIX } _${ escapedPersistenceKey } _(\\d+)(?:_(.*))?$`
580
575
) ;
581
576
this . queryTargetKeyRe = new RegExp (
582
- `^${ QUERY_TARGET_KEY_PREFIX } _${ this . escapedPersistenceKey } _(\\d+)$`
577
+ `^${ QUERY_TARGET_KEY_PREFIX } _${ escapedPersistenceKey } _(\\d+)$`
583
578
) ;
584
579
585
- this . onlineStateKey = `${ ONLINE_STATE_KEY_PREFIX } _${
586
- this . escapedPersistenceKey
587
- } `;
580
+ this . onlineStateKey = `${ ONLINE_STATE_KEY_PREFIX } _${ persistenceKey } ` ;
588
581
589
582
// Rather than adding the storage observer during start(), we add the
590
583
// storage observer during initialization. This ensures that we collect
@@ -926,22 +919,18 @@ export class WebStorageSharedClientState implements SharedClientState {
926
919
`Client key cannot contain '_', but was '${ clientId } '`
927
920
) ;
928
921
929
- return `${ CLIENT_STATE_KEY_PREFIX } _${
930
- this . escapedPersistenceKey
931
- } _${ clientId } `;
922
+ return `${ CLIENT_STATE_KEY_PREFIX } _${ this . persistenceKey } _${ clientId } ` ;
932
923
}
933
924
934
925
/** Assembles the key for a query state in WebStorage */
935
926
private toWebStorageQueryTargetMetadataKey ( targetId : TargetId ) : string {
936
- return `${ QUERY_TARGET_KEY_PREFIX } _${
937
- this . escapedPersistenceKey
938
- } _${ targetId } `;
927
+ return `${ QUERY_TARGET_KEY_PREFIX } _${ this . persistenceKey } _${ targetId } ` ;
939
928
}
940
929
941
930
/** Assembles the key for a mutation batch in WebStorage */
942
931
private toWebStorageMutationBatchKey ( batchId : BatchId ) : string {
943
932
let mutationKey = `${ MUTATION_BATCH_KEY_PREFIX } _${
944
- this . escapedPersistenceKey
933
+ this . persistenceKey
945
934
} _${ batchId } `;
946
935
947
936
if ( this . currentUser . isAuthenticated ( ) ) {
0 commit comments