Skip to content

Commit

Permalink
Allow aggregations to work with multi-tab.
Browse files Browse the repository at this point in the history
Fixes #7198.

A proper long-term solution for multi-tab should be implemented.
  • Loading branch information
ehsannas committed Apr 12, 2023
1 parent 8c44d58 commit d6255b9
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions packages/firestore/src/core/firestore_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { newSerializer } from '../platform/serializer';
import { newTextEncoder } from '../platform/text_serializer';
import { Datastore, invokeRunAggregationQueryRpc } from '../remote/datastore';
import {
canUseNetwork,
RemoteStore,
remoteStoreDisableNetwork,
remoteStoreEnableNetwork,
Expand Down Expand Up @@ -536,20 +535,11 @@ export function firestoreClientRunAggregateQuery(
// to the implementation in firestoreClientGetDocumentsViaSnapshotListener
// above
try {
const remoteStore = await getRemoteStore(client);
if (!canUseNetwork(remoteStore)) {
deferred.reject(
new FirestoreError(
Code.UNAVAILABLE,
'Failed to get aggregate result because the client is offline.'
)
);
} else {
const datastore = await getDatastore(client);
deferred.resolve(
invokeRunAggregationQueryRpc(datastore, query, aggregates)
);
}
// TODO(b/277628384): check `canUseNetwork()` and handle multi-tab.
const datastore = await getDatastore(client);
deferred.resolve(
invokeRunAggregationQueryRpc(datastore, query, aggregates)
);
} catch (e) {
deferred.reject(e as Error);
}
Expand Down

0 comments on commit d6255b9

Please sign in to comment.