Skip to content

Commit 9d7ccba

Browse files
Invoke RemoteStore's credential change listener even when user didn't change
1 parent a49c51c commit 9d7ccba

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

common/api-review/firestore-exp.api.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { _FirebaseService } from '@firebase/app-types-exp';
1111
import { LogLevelString as LogLevel } from '@firebase/logger';
1212
import { Provider } from '@firebase/component';
1313
import { SetOptions as SetOptions_2 } from '@firebase/firestore-types';
14-
import { SnapshotMetadata as SnapshotMetadata_2 } from '@firebase/firestore-types';
1514

1615
// @public
1716
export function addDoc<T>(reference: CollectionReference<T>, data: T): Promise<DocumentReference<T>>;
@@ -440,11 +439,11 @@ export interface SnapshotListenOptions {
440439
}
441440

442441
// @public
443-
export class SnapshotMetadata implements SnapshotMetadata_2 {
442+
export class SnapshotMetadata {
444443
constructor(hasPendingWrites: boolean, fromCache: boolean);
445444
readonly fromCache: boolean;
446445
readonly hasPendingWrites: boolean;
447-
isEqual(other: SnapshotMetadata_2): boolean;
446+
isEqual(other: SnapshotMetadata): boolean;
448447
}
449448

450449
// @public

common/api-review/firestore-lite.api.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ export abstract class FieldValue {
168168
abstract _toFieldTransform(context: ParseContext): FieldTransform | null;
169169
}
170170

171+
// Warning: (ae-forgotten-export) The symbol "FirestoreService" needs to be exported by the entry point index.d.ts
172+
//
171173
// @public
172-
export class FirebaseFirestore implements _FirebaseService {
174+
export class FirebaseFirestore implements FirestoreService {
173175
constructor(databaseIdOrApp: DatabaseId | FirebaseApp, authProvider: Provider<FirebaseAuthInternalName>);
174176
get app(): FirebaseApp;
175177
// Warning: (ae-forgotten-export) The symbol "CredentialsProvider" needs to be exported by the entry point index.d.ts

packages/firestore/src/core/firestore_client.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,8 @@ export class FirestoreClient {
118118
) {
119119
this.credentials.setChangeListener(user => {
120120
logDebug(LOG_TAG, 'Received user=', user.uid);
121-
if (!this.user.isEqual(user)) {
122-
this.user = user;
123-
this.credentialListener(user);
124-
}
121+
this.user = user;
122+
this.credentialListener(user);
125123
this.receivedInitialUser.resolve();
126124
});
127125
}
@@ -199,11 +197,15 @@ export async function setOfflineComponentProvider(
199197
const configuration = await client.getConfiguration();
200198
await offlineComponentProvider.initialize(configuration);
201199

202-
client.setCredentialChangeListener(user =>
203-
client.asyncQueue.enqueueRetryable(async () => {
204-
await handleUserChange(offlineComponentProvider.localStore, user);
205-
})
206-
);
200+
let currentUser = configuration.initialUser;
201+
client.setCredentialChangeListener(user => {
202+
if (!currentUser.isEqual(user)) {
203+
currentUser = user;
204+
client.asyncQueue.enqueueRetryable(async () => {
205+
await handleUserChange(offlineComponentProvider.localStore, user);
206+
});
207+
}
208+
});
207209

208210
// When a user calls clearPersistence() in one client, all other clients
209211
// need to be terminated to allow the delete to succeed.

0 commit comments

Comments
 (0)