Skip to content

Commit da4a69e

Browse files
[AUTOMATED]: Prettier Code Styling
1 parent 210a16e commit da4a69e

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

packages/firestore/src/local/indexeddb_persistence.ts

+37-30
Original file line numberDiff line numberDiff line change
@@ -251,40 +251,47 @@ export class IndexedDbPersistence implements Persistence {
251251
txn: SimpleDbTransaction
252252
): PersistencePromise<boolean> {
253253
const store = ownerStore(txn);
254-
return store.get('owner').next(currentPrimary => {
255-
const currentLeaseIsValid =
256-
currentPrimary !== null &&
257-
this.isWithinMaxAge(currentPrimary.leaseTimestampMs) &&
258-
currentPrimary.ownerId !== this.getZombiedClientId();
259-
260-
if (currentLeaseIsValid) {
261-
return this.isLocalClient(currentPrimary);
262-
}
263-
// Check if this client is eligible for a primary lease based on its
264-
// visibility state and the visibility state of all active clients. A
265-
// client can obtain the primary lease if it is either in the foreground
266-
// or if this client and all other clients are in the background.
267-
if (this.inForeground) {
268-
return true;
269-
}
254+
return store
255+
.get('owner')
256+
.next(currentPrimary => {
257+
const currentLeaseIsValid =
258+
currentPrimary !== null &&
259+
this.isWithinMaxAge(currentPrimary.leaseTimestampMs) &&
260+
currentPrimary.ownerId !== this.getZombiedClientId();
261+
262+
if (currentLeaseIsValid) {
263+
return this.isLocalClient(currentPrimary);
264+
}
265+
// Check if this client is eligible for a primary lease based on its
266+
// visibility state and the visibility state of all active clients. A
267+
// client can obtain the primary lease if it is either in the foreground
268+
// or if this client and all other clients are in the background.
269+
if (this.inForeground) {
270+
return true;
271+
}
270272

271-
let canActAsPrimary = true;
272-
return clientMetadataStore(txn)
273-
.iterate((key, value, control) => {
274-
if (this.clientKey !== value.clientKey) {
275-
if (this.isWithinMaxAge(value.updateTimeMs) && value.inForeground) {
276-
canActAsPrimary = false;
277-
control.done();
273+
let canActAsPrimary = true;
274+
return clientMetadataStore(txn)
275+
.iterate((key, value, control) => {
276+
if (this.clientKey !== value.clientKey) {
277+
if (
278+
this.isWithinMaxAge(value.updateTimeMs) &&
279+
value.inForeground
280+
) {
281+
canActAsPrimary = false;
282+
control.done();
283+
}
278284
}
279-
}
280-
}).next(() => canActAsPrimary)
281-
}).next(canActAsPrimary => {
285+
})
286+
.next(() => canActAsPrimary);
287+
})
288+
.next(canActAsPrimary => {
282289
if (this.isPrimary !== canActAsPrimary) {
283290
log.debug(
284-
LOG_TAG,
285-
`Client ${
286-
canActAsPrimary ? 'is' : 'is not'
287-
} eligible for a primary lease.`
291+
LOG_TAG,
292+
`Client ${
293+
canActAsPrimary ? 'is' : 'is not'
294+
} eligible for a primary lease.`
288295
);
289296
}
290297
return canActAsPrimary;

0 commit comments

Comments
 (0)