diff options
author | Konstantin Varlamov <var-const@users.noreply.github.com> | 2018-03-30 14:50:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-30 14:50:15 -0400 |
commit | a17740e9146e4e2431d62964d044287cccc3ee85 (patch) | |
tree | 479f280a07f4200924e0ef7cce183aa35e14c5bb /Firestore/Source/API/FIRFirestoreSettings.mm | |
parent | 653aea7b50247bb0f6a7e8e1b4ab782553849f74 (diff) |
Add a flag to control whether DocumentSnapshots return Dates or Timestamps for timestamp fields (#831)
* add a new property `timestampsInSnapshotsEnabled` to `FirestoreSettings`, `false` by default;
* add a verbose warning message urging users to opt into the new behavior;
* set `timestampsInSnapshotsEnabled` to true in the integration tests to reduce the verbose console
spam during the test run and make sure the flag won't break anything once it's flipped.
Diffstat (limited to 'Firestore/Source/API/FIRFirestoreSettings.mm')
-rw-r--r-- | Firestore/Source/API/FIRFirestoreSettings.mm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Firestore/Source/API/FIRFirestoreSettings.mm b/Firestore/Source/API/FIRFirestoreSettings.mm index 9677ff6..8f998ec 100644 --- a/Firestore/Source/API/FIRFirestoreSettings.mm +++ b/Firestore/Source/API/FIRFirestoreSettings.mm @@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN static NSString *const kDefaultHost = @"firestore.googleapis.com"; static const BOOL kDefaultSSLEnabled = YES; static const BOOL kDefaultPersistenceEnabled = YES; +// TODO(b/73820332): flip the default. +static const BOOL kDefaultTimestampsInSnapshotsEnabled = NO; @implementation FIRFirestoreSettings @@ -32,6 +34,7 @@ static const BOOL kDefaultPersistenceEnabled = YES; _sslEnabled = kDefaultSSLEnabled; _dispatchQueue = dispatch_get_main_queue(); _persistenceEnabled = kDefaultPersistenceEnabled; + _timestampsInSnapshotsEnabled = kDefaultTimestampsInSnapshotsEnabled; } return self; } @@ -47,7 +50,8 @@ static const BOOL kDefaultPersistenceEnabled = YES; return [self.host isEqual:otherSettings.host] && self.isSSLEnabled == otherSettings.isSSLEnabled && self.dispatchQueue == otherSettings.dispatchQueue && - self.isPersistenceEnabled == otherSettings.isPersistenceEnabled; + self.isPersistenceEnabled == otherSettings.isPersistenceEnabled && + self.timestampsInSnapshotsEnabled == otherSettings.timestampsInSnapshotsEnabled; } - (NSUInteger)hash { @@ -55,6 +59,7 @@ static const BOOL kDefaultPersistenceEnabled = YES; result = 31 * result + (self.isSSLEnabled ? 1231 : 1237); // Ignore the dispatchQueue to avoid having to deal with sizeof(dispatch_queue_t). result = 31 * result + (self.isPersistenceEnabled ? 1231 : 1237); + result = 31 * result + (self.timestampsInSnapshotsEnabled ? 1231 : 1237); return result; } @@ -64,6 +69,7 @@ static const BOOL kDefaultPersistenceEnabled = YES; copy.sslEnabled = _sslEnabled; copy.dispatchQueue = _dispatchQueue; copy.persistenceEnabled = _persistenceEnabled; + copy.timestampsInSnapshotsEnabled = _timestampsInSnapshotsEnabled; return copy; } |