diff options
author | Sebastian Schmidt <mrschmidt@google.com> | 2017-12-08 14:01:13 -0800 |
---|---|---|
committer | Sebastian Schmidt <mrschmidt@google.com> | 2017-12-08 14:02:23 -0800 |
commit | 84e7f27a3f1885cfe986b154283bcade52f4408d (patch) | |
tree | eb735c6ed16faad3c7074b434929689b864cbe93 /Firestore/Source | |
parent | bf48b0abc18e098c2579ddd3bcd8694269e2db25 (diff) |
Adding default option
Diffstat (limited to 'Firestore/Source')
-rw-r--r-- | Firestore/Source/API/FIRDocumentSnapshot.m | 3 | ||||
-rw-r--r-- | Firestore/Source/API/FIRSnapshotOptions.m | 9 | ||||
-rw-r--r-- | Firestore/Source/Model/FSTFieldValue.h | 2 | ||||
-rw-r--r-- | Firestore/Source/Model/FSTFieldValue.m | 8 | ||||
-rw-r--r-- | Firestore/Source/Public/FIRDocumentSnapshot.h | 14 |
5 files changed, 23 insertions, 13 deletions
diff --git a/Firestore/Source/API/FIRDocumentSnapshot.m b/Firestore/Source/API/FIRDocumentSnapshot.m index 7722927..c4e3040 100644 --- a/Firestore/Source/API/FIRDocumentSnapshot.m +++ b/Firestore/Source/API/FIRDocumentSnapshot.m @@ -135,7 +135,8 @@ NS_ASSUME_NONNULL_BEGIN } FSTFieldValue *fieldValue = [[self.internalDocument data] valueForPath:fieldPath.internalValue]; - return [self convertedValue:fieldValue options:[FSTFieldValueOptions optionsForSnapshotOptions:options]]; + return [self convertedValue:fieldValue + options:[FSTFieldValueOptions optionsForSnapshotOptions:options]]; } - (nullable id)objectForKeyedSubscript:(id)key { diff --git a/Firestore/Source/API/FIRSnapshotOptions.m b/Firestore/Source/API/FIRSnapshotOptions.m index 71d9d51..72ea3cc 100644 --- a/Firestore/Source/API/FIRSnapshotOptions.m +++ b/Firestore/Source/API/FIRSnapshotOptions.m @@ -29,7 +29,8 @@ NS_ASSUME_NONNULL_BEGIN @implementation FIRSnapshotOptions -- (instancetype)initWithServerTimestampBehavior:(FSTServerTimestampBehavior)serverTimestampBehavior { +- (instancetype)initWithServerTimestampBehavior: + (FSTServerTimestampBehavior)serverTimestampBehavior { self = [super init]; if (self) { @@ -44,8 +45,8 @@ NS_ASSUME_NONNULL_BEGIN static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - sharedInstance = [[FIRSnapshotOptions alloc] - initWithServerTimestampBehavior:FSTServerTimestampBehaviorDefault]; + sharedInstance = + [[FIRSnapshotOptions alloc] initWithServerTimestampBehavior:FSTServerTimestampBehaviorNone]; }); return sharedInstance; @@ -59,6 +60,8 @@ NS_ASSUME_NONNULL_BEGIN case FIRServerTimestampBehaviorPrevious: return [[FIRSnapshotOptions alloc] initWithServerTimestampBehavior:FSTServerTimestampBehaviorPrevious]; + case FIRServerTimestampBehaviorNone: + return [FIRSnapshotOptions defaultOptions]; default: FSTFail(@"Encountered unknown server timestamp behavior: %d", (int)serverTimestampBehavior); } diff --git a/Firestore/Source/Model/FSTFieldValue.h b/Firestore/Source/Model/FSTFieldValue.h index 991fb67..fe15865 100644 --- a/Firestore/Source/Model/FSTFieldValue.h +++ b/Firestore/Source/Model/FSTFieldValue.h @@ -44,9 +44,9 @@ typedef NS_ENUM(NSInteger, FSTTypeOrder) { /** Defines the return value for pending server timestamps. */ typedef NS_ENUM(NSInteger, FSTServerTimestampBehavior) { - FSTServerTimestampBehaviorDefault, FSTServerTimestampBehaviorEstimate, FSTServerTimestampBehaviorPrevious, + FSTServerTimestampBehaviorNone }; /** Holds properties that define field value deserialization options. */ diff --git a/Firestore/Source/Model/FSTFieldValue.m b/Firestore/Source/Model/FSTFieldValue.m index e26bc28..a6326a7 100644 --- a/Firestore/Source/Model/FSTFieldValue.m +++ b/Firestore/Source/Model/FSTFieldValue.m @@ -33,13 +33,13 @@ NS_ASSUME_NONNULL_BEGIN @implementation FSTFieldValueOptions + (instancetype)optionsForSnapshotOptions:(FIRSnapshotOptions *)options { - if (options.serverTimestampBehavior == FSTServerTimestampBehaviorDefault) { + if (options.serverTimestampBehavior == FSTServerTimestampBehaviorNone) { static FSTFieldValueOptions *defaultInstance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ defaultInstance = [[FSTFieldValueOptions alloc] - initWithServerTimestampBehavior:FSTServerTimestampBehaviorDefault]; + initWithServerTimestampBehavior:FSTServerTimestampBehaviorNone]; }); return defaultInstance; } else { @@ -74,7 +74,7 @@ NS_ASSUME_NONNULL_BEGIN - (id)value { return [self valueWithOptions:[FSTFieldValueOptions - optionsForSnapshotOptions:[FIRSnapshotOptions defaultOptions]]]; + optionsForSnapshotOptions:[FIRSnapshotOptions defaultOptions]]]; } - (id)valueWithOptions:(FSTFieldValueOptions *)options { @@ -470,7 +470,7 @@ NS_ASSUME_NONNULL_BEGIN - (id)valueWithOptions:(FSTFieldValueOptions *)options { switch (options.serverTimestampBehavior) { - case FSTServerTimestampBehaviorDefault: + case FSTServerTimestampBehaviorNone: return [NSNull null]; case FSTServerTimestampBehaviorEstimate: return [self.localWriteTime approximateDateValue]; diff --git a/Firestore/Source/Public/FIRDocumentSnapshot.h b/Firestore/Source/Public/FIRDocumentSnapshot.h index 0b72fe4..e8e73c9 100644 --- a/Firestore/Source/Public/FIRDocumentSnapshot.h +++ b/Firestore/Source/Public/FIRDocumentSnapshot.h @@ -39,6 +39,12 @@ typedef NS_ENUM(NSInteger, FIRServerTimestampBehavior) { * have not yet been set to their final value. */ FIRServerTimestampBehaviorPrevious, + + /** + * Return `NSNull` for `FieldValue.serverTimestamp()` fields that have not yet + * been set to their final value. + */ + FIRServerTimestampBehaviorNone }; /** @@ -102,8 +108,8 @@ NS_SWIFT_NAME(DocumentSnapshot) /** * Retrieves all fields in the document as a `Dictionary`. * - * @param options `SnapshotOptions` to configure how data is returned from - * the snapshot (e.g. the desired behavior for server timestamps that have not + * @param options `SnapshotOptions` to configure how data is returned from the + * snapshot (e.g. the desired behavior for server timestamps that have not * yet been set to their final value). * @return A `Dictionary` containing all fields in the document. */ @@ -129,8 +135,8 @@ NS_SWIFT_NAME(DocumentSnapshot) * configure this behavior. * * @param field The field to retrieve. - * @param options `SnapshotOptions` to configure how data is returned from - * the snapshot (e.g. the desired behavior for server timestamps that have not + * @param options `SnapshotOptions` to configure how data is returned from the + * snapshot (e.g. the desired behavior for server timestamps that have not * yet been set to their final value). * @return The value contained in the field or `nil` if the field doesn't exist. */ |