diff options
Diffstat (limited to 'Firestore/Source/Model/FSTMutationBatch.mm')
-rw-r--r-- | Firestore/Source/Model/FSTMutationBatch.mm | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/Firestore/Source/Model/FSTMutationBatch.mm b/Firestore/Source/Model/FSTMutationBatch.mm index e62a72c..3c03bdc 100644 --- a/Firestore/Source/Model/FSTMutationBatch.mm +++ b/Firestore/Source/Model/FSTMutationBatch.mm @@ -16,9 +16,10 @@ #import "Firestore/Source/Model/FSTMutationBatch.h" +#include <utility> + #import "FIRTimestamp.h" -#import "Firestore/Source/Core/FSTSnapshotVersion.h" #import "Firestore/Source/Model/FSTDocument.h" #import "Firestore/Source/Model/FSTMutation.h" #import "Firestore/Source/Util/FSTAssert.h" @@ -26,6 +27,7 @@ #include "Firestore/core/src/firebase/firestore/model/document_key.h" using firebase::firestore::model::DocumentKey; +using firebase::firestore::model::SnapshotVersion; NS_ASSUME_NONNULL_BEGIN @@ -127,22 +129,24 @@ const FSTBatchID kFSTBatchIDUnknown = -1; @interface FSTMutationBatchResult () - (instancetype)initWithBatch:(FSTMutationBatch *)batch - commitVersion:(FSTSnapshotVersion *)commitVersion + commitVersion:(SnapshotVersion)commitVersion mutationResults:(NSArray<FSTMutationResult *> *)mutationResults streamToken:(nullable NSData *)streamToken docVersions:(FSTDocumentVersionDictionary *)docVersions NS_DESIGNATED_INITIALIZER; @end -@implementation FSTMutationBatchResult +@implementation FSTMutationBatchResult { + SnapshotVersion _commitVersion; +} - (instancetype)initWithBatch:(FSTMutationBatch *)batch - commitVersion:(FSTSnapshotVersion *)commitVersion + commitVersion:(SnapshotVersion)commitVersion mutationResults:(NSArray<FSTMutationResult *> *)mutationResults streamToken:(nullable NSData *)streamToken docVersions:(FSTDocumentVersionDictionary *)docVersions { if (self = [super init]) { _batch = batch; - _commitVersion = commitVersion; + _commitVersion = std::move(commitVersion); _mutationResults = mutationResults; _streamToken = streamToken; _docVersions = docVersions; @@ -150,8 +154,12 @@ const FSTBatchID kFSTBatchIDUnknown = -1; return self; } +- (const SnapshotVersion &)commitVersion { + return _commitVersion; +} + + (instancetype)resultWithBatch:(FSTMutationBatch *)batch - commitVersion:(FSTSnapshotVersion *)commitVersion + commitVersion:(SnapshotVersion)commitVersion mutationResults:(NSArray<FSTMutationResult *> *)mutationResults streamToken:(nullable NSData *)streamToken { FSTAssert(batch.mutations.count == mutationResults.count, @@ -162,18 +170,18 @@ const FSTBatchID kFSTBatchIDUnknown = -1; [FSTDocumentVersionDictionary documentVersionDictionary]; NSArray<FSTMutation *> *mutations = batch.mutations; for (NSUInteger i = 0; i < mutations.count; i++) { - FSTSnapshotVersion *_Nullable version = mutationResults[i].version; + absl::optional<SnapshotVersion> version = mutationResults[i].version; if (!version) { // deletes don't have a version, so we substitute the commitVersion // of the entire batch. version = commitVersion; } - docVersions = [docVersions dictionaryBySettingObject:version forKey:mutations[i].key]; + docVersions = [docVersions dictionaryBySettingObject:version.value() forKey:mutations[i].key]; } return [[FSTMutationBatchResult alloc] initWithBatch:batch - commitVersion:commitVersion + commitVersion:std::move(commitVersion) mutationResults:mutationResults streamToken:streamToken docVersions:docVersions]; |