Skip to content

Commit 9f25aab

Browse files
committed
use hasCachedResults instead of resumeToken
1 parent 67d0ee7 commit 9f25aab

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

packages/firestore/src/core/event_manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export class QueryListener {
308308
snap.fromCache,
309309
snap.syncStateChanged,
310310
/* excludesMetadataChanges= */ true,
311-
snap.resumeToken
311+
snap.hasCachedResults
312312
);
313313
}
314314
let raisedEvent = false;
@@ -376,7 +376,7 @@ export class QueryListener {
376376
// or we are offline.
377377
return (
378378
!snap.docs.isEmpty() ||
379-
snap.resumeToken.approximateByteSize() > 0 ||
379+
snap.hasCachedResults ||
380380
onlineState === OnlineState.Offline
381381
);
382382
}
@@ -412,7 +412,7 @@ export class QueryListener {
412412
snap.docs,
413413
snap.mutatedKeys,
414414
snap.fromCache,
415-
snap.resumeToken
415+
snap.hasCachedResults
416416
);
417417
this.raisedInitialEvent = true;
418418
this.queryObserver.next(snap);

packages/firestore/src/core/view.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { DocumentKey } from '../model/document_key';
2626
import { DocumentSet } from '../model/document_set';
2727
import { TargetChange } from '../remote/remote_event';
2828
import { debugAssert, fail } from '../util/assert';
29-
import { ByteString } from '../util/byte_string';
3029

3130
import { LimitType, newQueryComparator, Query, queryMatches } from './query';
3231
import { OnlineState } from './types';
@@ -73,7 +72,7 @@ export interface ViewChange {
7372
*/
7473
export class View {
7574
private syncState: SyncState | null = null;
76-
private resumeToken: ByteString | null = null;
75+
private hasCachedResults: boolean = false;
7776
/**
7877
* A flag whether the view is current with the backend. A view is considered
7978
* current after it has seen the current flag from the backend and did not
@@ -322,7 +321,8 @@ export class View {
322321
newSyncState === SyncState.Local,
323322
syncStateChanged,
324323
/* excludesMetadataChanges= */ false,
325-
targetChange?.resumeToken ?? ByteString.EMPTY_BYTE_STRING
324+
targetChange !== undefined &&
325+
targetChange.resumeToken.approximateByteSize() > 0
326326
);
327327
return {
328328
snapshot: snap,
@@ -472,7 +472,7 @@ export class View {
472472
this.documentSet,
473473
this.mutatedKeys,
474474
this.syncState === SyncState.Local,
475-
this.resumeToken ?? ByteString.EMPTY_BYTE_STRING
475+
this.hasCachedResults
476476
);
477477
}
478478
}

packages/firestore/src/core/view_snapshot.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { Document } from '../model/document';
2020
import { DocumentKey } from '../model/document_key';
2121
import { DocumentSet } from '../model/document_set';
2222
import { fail } from '../util/assert';
23-
import { ByteString } from '../util/byte_string';
2423
import { SortedMap } from '../util/sorted_map';
2524

2625
import { Query, queryEquals } from './query';
@@ -148,7 +147,7 @@ export class ViewSnapshot {
148147
readonly fromCache: boolean,
149148
readonly syncStateChanged: boolean,
150149
readonly excludesMetadataChanges: boolean,
151-
readonly resumeToken: ByteString
150+
readonly hasCachedResults: boolean
152151
) {}
153152

154153
/** Returns a view snapshot as if all documents in the snapshot were added. */
@@ -157,7 +156,7 @@ export class ViewSnapshot {
157156
documents: DocumentSet,
158157
mutatedKeys: DocumentKeySet,
159158
fromCache: boolean,
160-
resumeToken: ByteString
159+
hasCachedResults: boolean
161160
): ViewSnapshot {
162161
const changes: DocumentViewChange[] = [];
163162
documents.forEach(doc => {
@@ -173,7 +172,7 @@ export class ViewSnapshot {
173172
fromCache,
174173
/* syncStateChanged= */ true,
175174
/* excludesMetadataChanges= */ false,
176-
resumeToken
175+
hasCachedResults
177176
);
178177
}
179178

packages/firestore/test/util/api_helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export function querySnapshot(
155155
fromCache,
156156
syncStateChanged,
157157
false,
158-
resumeToken ?? ByteString.EMPTY_BYTE_STRING
158+
resumeToken !== undefined && resumeToken.approximateByteSize() > 0
159159
);
160160
const db = firestore();
161161
return new QuerySnapshot(

0 commit comments

Comments
 (0)