diff options
Diffstat (limited to 'Firestore/Source/Core/FSTView.mm')
-rw-r--r-- | Firestore/Source/Core/FSTView.mm | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/Firestore/Source/Core/FSTView.mm b/Firestore/Source/Core/FSTView.mm index 63efd4e..f954731 100644 --- a/Firestore/Source/Core/FSTView.mm +++ b/Firestore/Source/Core/FSTView.mm @@ -401,28 +401,18 @@ static NSComparisonResult FSTCompareDocumentViewChangeTypes(FSTDocumentViewChang */ - (void)applyTargetChange:(nullable FSTTargetChange *)targetChange { if (targetChange) { - FSTTargetMapping *targetMapping = targetChange.mapping; - if ([targetMapping isKindOfClass:[FSTResetMapping class]]) { - _syncedDocuments = ((FSTResetMapping *)targetMapping).documents; - } else if ([targetMapping isKindOfClass:[FSTUpdateMapping class]]) { - for (const DocumentKey &key : ((FSTUpdateMapping *)targetMapping).addedDocuments) { - _syncedDocuments = _syncedDocuments.insert(key); - } - for (const DocumentKey &key : ((FSTUpdateMapping *)targetMapping).removedDocuments) { - _syncedDocuments = _syncedDocuments.erase(key); - } + for (const DocumentKey &key : targetChange.addedDocuments) { + _syncedDocuments = _syncedDocuments.insert(key); } - - switch (targetChange.currentStatusUpdate) { - case FSTCurrentStatusUpdateMarkCurrent: - self.current = YES; - break; - case FSTCurrentStatusUpdateMarkNotCurrent: - self.current = NO; - break; - case FSTCurrentStatusUpdateNone: - break; + for (const DocumentKey &key : targetChange.modifiedDocuments) { + HARD_ASSERT(_syncedDocuments.find(key) != _syncedDocuments.end(), + "Modified document %s not found in view.", key.ToString()); } + for (const DocumentKey &key : targetChange.removedDocuments) { + _syncedDocuments = _syncedDocuments.erase(key); + } + + self.current = targetChange.current; } } |