From b3050e42d842a4aef122efd277481c46bfa88dff Mon Sep 17 00:00:00 2001 From: zxu Date: Sat, 24 Mar 2018 11:06:32 -0400 Subject: port C++ `DocumentKey` to `Remote/*` (#965) * port C++ DocumentKey to Remote's * port C++ DocumentKey to Remote's * address changes * address changes * address changes --- Firestore/Source/Core/FSTSyncEngine.mm | 6 ++---- Firestore/Source/Core/FSTTransaction.h | 6 +++++- Firestore/Source/Core/FSTTransaction.mm | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'Firestore/Source/Core') diff --git a/Firestore/Source/Core/FSTSyncEngine.mm b/Firestore/Source/Core/FSTSyncEngine.mm index d567878..b1f138a 100644 --- a/Firestore/Source/Core/FSTSyncEngine.mm +++ b/Firestore/Source/Core/FSTSyncEngine.mm @@ -300,7 +300,7 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1; FSTTargetChange *_Nonnull targetChange, BOOL *_Nonnull stop) { FSTDocumentKey *limboKey = self.limboKeysByTarget[targetID]; if (limboKey && targetChange.currentStatusUpdate == FSTCurrentStatusUpdateMarkCurrent && - remoteEvent.documentUpdates[limboKey] == nil) { + remoteEvent.documentUpdates.find(limboKey) == remoteEvent.documentUpdates.end()) { // When listening to a query the server responds with a snapshot containing documents // matching the query and a current marker telling us we're now in sync. It's possible for // these to arrive as separate remote events or as a single remote event. For a document @@ -363,11 +363,9 @@ static const FSTListenSequenceNumber kIrrelevantSequenceNumber = -1; [NSMutableDictionary dictionary]; FSTDeletedDocument *doc = [FSTDeletedDocument documentWithKey:limboKey version:[FSTSnapshotVersion noVersion]]; - NSMutableDictionary *docUpdate = - [NSMutableDictionary dictionaryWithObject:doc forKey:limboKey]; FSTRemoteEvent *event = [FSTRemoteEvent eventWithSnapshotVersion:[FSTSnapshotVersion noVersion] targetChanges:targetChanges - documentUpdates:docUpdate]; + documentUpdates:{{limboKey, doc}}]; [self applyRemoteEvent:event]; } else { FSTQueryView *queryView = self.queryViewsByTarget[targetID]; diff --git a/Firestore/Source/Core/FSTTransaction.h b/Firestore/Source/Core/FSTTransaction.h index d4f3d8d..4e5441b 100644 --- a/Firestore/Source/Core/FSTTransaction.h +++ b/Firestore/Source/Core/FSTTransaction.h @@ -16,8 +16,12 @@ #import +#include + #import "Firestore/Source/Core/FSTTypes.h" +#include "Firestore/core/src/firebase/firestore/model/document_key.h" + @class FIRSetOptions; @class FSTDatastore; @class FSTDocumentKey; @@ -42,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN * Takes a set of keys and asynchronously attempts to fetch all the documents from the backend, * ignoring any local changes. */ -- (void)lookupDocumentsForKeys:(NSArray *)keys +- (void)lookupDocumentsForKeys:(const std::vector &)keys completion:(FSTVoidMaybeDocumentArrayErrorBlock)completion; /** diff --git a/Firestore/Source/Core/FSTTransaction.mm b/Firestore/Source/Core/FSTTransaction.mm index b980a4e..58f2dd7 100644 --- a/Firestore/Source/Core/FSTTransaction.mm +++ b/Firestore/Source/Core/FSTTransaction.mm @@ -16,6 +16,8 @@ #import "Firestore/Source/Core/FSTTransaction.h" +#include + #import #import "FIRFirestoreErrors.h" @@ -32,6 +34,8 @@ #include "Firestore/core/src/firebase/firestore/model/document_key.h" +using firebase::firestore::model::DocumentKey; + NS_ASSUME_NONNULL_BEGIN #pragma mark - FSTTransaction @@ -99,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN } } -- (void)lookupDocumentsForKeys:(NSArray *)keys +- (void)lookupDocumentsForKeys:(const std::vector &)keys completion:(FSTVoidMaybeDocumentArrayErrorBlock)completion { [self ensureCommitNotCalled]; if (self.mutations.count) { -- cgit v1.2.3