diff options
author | Sebastian Schmidt <mrschmidt@google.com> | 2018-06-12 10:58:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-12 10:58:35 -0700 |
commit | afea8d5aacf474b57b4364feda08be9ca195594b (patch) | |
tree | d43c39ae9f71e88d256012f4467cd2b707fc7ddd /Firestore/Source/Core/FSTView.mm | |
parent | 0db8ef7dbe6c8c191252d33090dbb88b98735148 (diff) |
Refactor Remote Event (#1396)
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; } } |