Skip to content

Commit 24a3713

Browse files
Remove newly redundant synced flag
1 parent 29a1573 commit 24a3713

File tree

10 files changed

+11
-43
lines changed

10 files changed

+11
-43
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/core/QueryListener.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public void onViewSnapshot(ViewSnapshot newSnapshot) {
8080
documentChanges,
8181
newSnapshot.isFromCache(),
8282
newSnapshot.getMutatedKeys(),
83-
newSnapshot.isSynced(),
8483
newSnapshot.didSyncStateChange(),
8584
/* excludesMetadataChanges= */ true);
8685
}
@@ -159,7 +158,6 @@ private void raiseInitialEvent(ViewSnapshot snapshot) {
159158
snapshot.getDocuments(),
160159
snapshot.getMutatedKeys(),
161160
snapshot.isFromCache(),
162-
snapshot.isSynced(),
163161
snapshot.excludesMetadataChanges());
164162
raisedInitialEvent = true;
165163
listener.onEvent(snapshot, null);

firebase-firestore/src/main/java/com/google/firebase/firestore/core/View.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ public ViewChange applyChanges(DocumentChanges docChanges, TargetChange targetCh
311311
viewChanges,
312312
fromCache,
313313
docChanges.mutatedKeys,
314-
synced,
315314
syncStatedChanged,
316315
/* excludesMetadataChanges= */ false);
317316
}

firebase-firestore/src/main/java/com/google/firebase/firestore/core/ViewSnapshot.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public enum SyncState {
3737
private final List<DocumentViewChange> changes;
3838
private final boolean isFromCache;
3939
private final ImmutableSortedSet<DocumentKey> mutatedKeys;
40-
private final boolean synced;
4140
private final boolean didSyncStateChange;
4241
private boolean excludesMetadataChanges;
4342

@@ -48,7 +47,6 @@ public ViewSnapshot(
4847
List<DocumentViewChange> changes,
4948
boolean isFromCache,
5049
ImmutableSortedSet<DocumentKey> mutatedKeys,
51-
boolean synced,
5250
boolean didSyncStateChange,
5351
boolean excludesMetadataChanges) {
5452
this.query = query;
@@ -57,7 +55,6 @@ public ViewSnapshot(
5755
this.changes = changes;
5856
this.isFromCache = isFromCache;
5957
this.mutatedKeys = mutatedKeys;
60-
this.synced = synced;
6158
this.didSyncStateChange = didSyncStateChange;
6259
this.excludesMetadataChanges = excludesMetadataChanges;
6360
}
@@ -68,7 +65,6 @@ public static ViewSnapshot fromInitialDocuments(
6865
DocumentSet documents,
6966
ImmutableSortedSet<DocumentKey> mutatedKeys,
7067
boolean fromCache,
71-
boolean synced,
7268
boolean excludesMetadataChanges) {
7369
List<DocumentViewChange> viewChanges = new ArrayList<>();
7470
for (Document doc : documents) {
@@ -81,7 +77,6 @@ public static ViewSnapshot fromInitialDocuments(
8177
viewChanges,
8278
fromCache,
8379
mutatedKeys,
84-
synced,
8580
/* didSyncStateChange= */ true,
8681
excludesMetadataChanges);
8782
}
@@ -90,10 +85,6 @@ public Query getQuery() {
9085
return query;
9186
}
9287

93-
public boolean isSynced() {
94-
return synced;
95-
}
96-
9788
public DocumentSet getDocuments() {
9889
return documents;
9990
}
@@ -140,9 +131,6 @@ public final boolean equals(Object o) {
140131
if (isFromCache != that.isFromCache) {
141132
return false;
142133
}
143-
if (synced != that.synced) {
144-
return false;
145-
}
146134
if (didSyncStateChange != that.didSyncStateChange) {
147135
return false;
148136
}
@@ -172,7 +160,6 @@ public int hashCode() {
172160
result = 31 * result + changes.hashCode();
173161
result = 31 * result + mutatedKeys.hashCode();
174162
result = 31 * result + (isFromCache ? 1 : 0);
175-
result = 31 * result + (synced ? 1 : 0);
176163
result = 31 * result + (didSyncStateChange ? 1 : 0);
177164
result = 31 * result + (excludesMetadataChanges ? 1 : 0);
178165
return result;
@@ -192,8 +179,6 @@ public String toString() {
192179
+ isFromCache
193180
+ ", mutatedKeys="
194181
+ mutatedKeys.size()
195-
+ ", synced="
196-
+ synced
197182
+ ", didSyncStateChange="
198183
+ didSyncStateChange
199184
+ ", excludesMetadataChanges="

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public void notifyLocalViewChanges(List<LocalViewChanges> viewChanges) {
478478
}
479479
localViewReferences.removeReferences(removed, targetId);
480480

481-
if (viewChange.isSynced()) {
481+
if (!viewChange.isFromCache()) {
482482
QueryData queryData = targetIds.get(targetId);
483483
hardAssert(
484484
queryData != null,

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalViewChanges.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ public static LocalViewChanges fromViewSnapshot(int targetId, ViewSnapshot snaps
4949
}
5050
}
5151

52-
return new LocalViewChanges(targetId, snapshot.isSynced(), addedKeys, removedKeys);
52+
return new LocalViewChanges(targetId, snapshot.isFromCache(), addedKeys, removedKeys);
5353
}
5454

5555
private final int targetId;
56-
private final boolean synced;
56+
private final boolean fromCache;
5757

5858
private final ImmutableSortedSet<DocumentKey> added;
5959
private final ImmutableSortedSet<DocumentKey> removed;
6060

6161
public LocalViewChanges(
6262
int targetId,
63-
boolean synced,
63+
boolean fromCache,
6464
ImmutableSortedSet<DocumentKey> added,
6565
ImmutableSortedSet<DocumentKey> removed) {
6666
this.targetId = targetId;
67-
this.synced = synced;
67+
this.fromCache = fromCache;
6868
this.added = added;
6969
this.removed = removed;
7070
}
@@ -73,8 +73,8 @@ public int getTargetId() {
7373
return targetId;
7474
}
7575

76-
public boolean isSynced() {
77-
return synced;
76+
public boolean isFromCache() {
77+
return fromCache;
7878
}
7979

8080
public ImmutableSortedSet<DocumentKey> getAdded() {

firebase-firestore/src/roboUtil/java/com/google/firebase/firestore/TestUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ public static QuerySnapshot querySnapshot(
129129
documentChanges,
130130
isFromCache,
131131
mutatedKeys,
132-
/* synced= */ false,
133132
/* didSyncStateChange= */ true,
134133
/* excludesMetadataChanges= */ false);
135134
return new QuerySnapshot(query(path), viewSnapshot, FIRESTORE);

firebase-firestore/src/test/java/com/google/firebase/firestore/QuerySnapshotTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public void testIncludeMetadataChanges() {
125125
documentChanges,
126126
/*isFromCache=*/ false,
127127
/*mutatedKeys=*/ keySet(),
128-
/*isSynced=*/ true,
129128
/*didSyncStateChange=*/ true,
130129
/* excludesMetadataChanges= */ false);
131130

firebase-firestore/src/test/java/com/google/firebase/firestore/core/QueryListenerTest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public void testRaisesCollectionEvents() {
108108
asList(change1, change4),
109109
snap2.isFromCache(),
110110
snap2.getMutatedKeys(),
111-
/* synced= */ false,
112111
/* didSyncStateChange= */ true,
113112
/* excludesMetadataChanges= */ false);
114113
assertEquals(asList(snap2Prime), otherAccum);
@@ -266,7 +265,6 @@ public void testRaisesQueryMetadataEventsOnlyWhenHasPendingWritesOnTheQueryChang
266265
asList(),
267266
snap4.isFromCache(),
268267
snap4.getMutatedKeys(),
269-
snap4.isSynced(),
270268
snap4.didSyncStateChange(),
271269
/* excludeMetadataChanges= */ true); // This test excludes document metadata changes
272270

@@ -308,7 +306,6 @@ public void testMetadataOnlyDocumentChangesAreFilteredOut() {
308306
asList(change3),
309307
snap2.isFromCache(),
310308
snap2.getMutatedKeys(),
311-
snap2.isSynced(),
312309
snap2.didSyncStateChange(),
313310
/* excludesMetadataChanges= */ true);
314311
assertEquals(
@@ -351,7 +348,6 @@ public void testWillWaitForSyncIfOnline() {
351348
asList(change1, change2),
352349
/* isFromCache= */ false,
353350
snap3.getMutatedKeys(),
354-
/* synced= */ true,
355351
/* didSyncStateChange= */ true,
356352
/* excludesMetadataChanges= */ true);
357353
assertEquals(asList(expectedSnapshot), events);
@@ -390,7 +386,6 @@ public void testWillRaiseInitialEventWhenGoingOffline() {
390386
asList(change1),
391387
/* isFromCache= */ true,
392388
snap1.getMutatedKeys(),
393-
snap1.isSynced(),
394389
/* didSyncStateChange= */ true,
395390
/* excludesMetadataChanges= */ true);
396391
ViewSnapshot expectedSnapshot2 =
@@ -401,7 +396,6 @@ public void testWillRaiseInitialEventWhenGoingOffline() {
401396
asList(change2),
402397
/* isFromCache= */ true,
403398
snap2.getMutatedKeys(),
404-
snap2.isSynced(),
405399
/* didSyncStateChange= */ false,
406400
/* excludesMetadataChanges= */ true);
407401
assertEquals(asList(expectedSnapshot1, expectedSnapshot2), events);
@@ -429,7 +423,6 @@ public void testWillRaiseInitialEventWhenGoingOfflineAndThereAreNoDocs() {
429423
asList(),
430424
/* isFromCache= */ true,
431425
snap1.getMutatedKeys(),
432-
snap1.isSynced(),
433426
/* didSyncStateChange= */ true,
434427
/* excludesMetadataChanges= */ true);
435428
assertEquals(asList(expectedSnapshot), events);
@@ -456,7 +449,6 @@ public void testWillRaiseInitialEventWhenStartingOfflineAndThereAreNoDocs() {
456449
asList(),
457450
/* isFromCache= */ true,
458451
snap1.getMutatedKeys(),
459-
snap1.isSynced(),
460452
/* didSyncStateChange= */ true,
461453
/* excludesMetadataChanges= */ true);
462454
assertEquals(asList(expectedSnapshot), events);
@@ -470,7 +462,6 @@ private ViewSnapshot applyExpectedMetadata(ViewSnapshot snap, MetadataChanges me
470462
snap.getChanges(),
471463
snap.isFromCache(),
472464
snap.getMutatedKeys(),
473-
snap.isSynced(),
474465
snap.didSyncStateChange(),
475466
MetadataChanges.EXCLUDE.equals(metadata));
476467
}

firebase-firestore/src/test/java/com/google/firebase/firestore/core/ViewSnapshotTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public void testConstructor() {
4545
List<DocumentViewChange> changes =
4646
Arrays.asList(DocumentViewChange.create(Type.ADDED, doc("c/foo", 1, map())));
4747
ImmutableSortedSet<DocumentKey> mutatedKeys = keySet(key("c/foo"));
48-
boolean synced = true;
4948
boolean fromCache = true;
5049
boolean hasPendingWrites = true;
5150
boolean syncStateChanges = true;
@@ -59,7 +58,6 @@ public void testConstructor() {
5958
changes,
6059
fromCache,
6160
mutatedKeys,
62-
synced,
6361
syncStateChanges,
6462
excludesMetadataChanges);
6563

@@ -69,7 +67,6 @@ public void testConstructor() {
6967
assertEquals(changes, snapshot.getChanges());
7068
assertEquals(fromCache, snapshot.isFromCache());
7169
assertEquals(mutatedKeys, snapshot.getMutatedKeys());
72-
assertEquals(synced, snapshot.isSynced());
7370
assertEquals(hasPendingWrites, snapshot.hasPendingWrites());
7471
assertEquals(syncStateChanges, snapshot.didSyncStateChange());
7572
assertEquals(excludesMetadataChanges, snapshot.excludesMetadataChanges());

firebase-firestore/src/test/java/com/google/firebase/firestore/core/ViewTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public void testKeepsTrackOfLimboDocuments() {
302302
}
303303

304304
@Test
305-
public void testViewsWithLimboDocumentsAreNotMarkedSynced() {
305+
public void testViewsWithLimboDocumentsAreNotMarkedFromCache() {
306306
Query query = messageQuery();
307307
View view = new View(query, DocumentKey.emptyKeySet());
308308
Document doc1 = doc("rooms/eros/messages/0", 0, map());
@@ -311,20 +311,20 @@ public void testViewsWithLimboDocumentsAreNotMarkedSynced() {
311311
// Doc1 is contained in the local view, but we are not yet CURRENT so it is expected that the
312312
// backend hasn't told us about all documents yet.
313313
ViewChange change = applyChanges(view, doc1);
314-
assertFalse(change.getSnapshot().isSynced());
314+
assertTrue(change.getSnapshot().isFromCache());
315315

316316
// Add doc2 to generate a snapshot. Doc1 is still missing.
317317
View.DocumentChanges viewDocChanges = view.computeDocChanges(docUpdates(doc2));
318318
change =
319319
view.applyChanges(
320320
viewDocChanges, targetChange(ByteString.EMPTY, true, asList(doc2), null, null));
321-
assertFalse(change.getSnapshot().isSynced()); // We are CURRENT but doc1 is in limbo.
321+
assertTrue(change.getSnapshot().isFromCache()); // We are CURRENT but doc1 is in limbo.
322322

323323
// Add doc1 to the backend's result set.
324324
change =
325325
view.applyChanges(
326326
viewDocChanges, targetChange(ByteString.EMPTY, true, asList(doc1), null, null));
327-
assertTrue(change.getSnapshot().isSynced());
327+
assertFalse(change.getSnapshot().isFromCache());
328328
}
329329

330330
@Test

0 commit comments

Comments
 (0)