always specify default when accessing bool preference

pull/2/head
Michael Kirk 6 years ago
parent 39d3219238
commit 21cffdfb5e

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "OWSReadReceiptManager.h"
@ -524,22 +524,9 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
{
// We don't need to worry about races around this cached value.
if (!self.areReadReceiptsEnabledCached) {
// Default to NO.
self.areReadReceiptsEnabledCached = @([self.dbConnection boolForKey:OWSReadReceiptManagerAreReadReceiptsEnabled
inCollection:OWSReadReceiptManagerCollection]);
}
return [self.areReadReceiptsEnabledCached boolValue];
}
- (BOOL)areReadReceiptsEnabledWithTransaction:(YapDatabaseReadTransaction *)transaction
{
if (!self.areReadReceiptsEnabledCached) {
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
// Default to NO.
self.areReadReceiptsEnabledCached = [transaction objectForKey:OWSReadReceiptManagerAreReadReceiptsEnabled
inCollection:OWSReadReceiptManagerCollection];
}];
inCollection:OWSReadReceiptManagerCollection
defaultValue:NO]);
}
return [self.areReadReceiptsEnabledCached boolValue];

@ -104,7 +104,8 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
{
return
[[OWSPrimaryStorage dbReadConnection] boolForKey:kOWSPrimaryStorage_isCensorshipCircumventionManuallyActivated
inCollection:kOWSPrimaryStorage_OWSSignalService];
inCollection:kOWSPrimaryStorage_OWSSignalService
defaultValue:NO];
}
- (void)setIsCensorshipCircumventionManuallyActivated:(BOOL)value
@ -119,7 +120,8 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
- (BOOL)isCensorshipCircumventionManuallyDisabled
{
return [[OWSPrimaryStorage dbReadConnection] boolForKey:kOWSPrimaryStorage_isCensorshipCircumventionManuallyDisabled
inCollection:kOWSPrimaryStorage_OWSSignalService];
inCollection:kOWSPrimaryStorage_OWSSignalService
defaultValue:NO];
}
- (void)setIsCensorshipCircumventionManuallyDisabled:(BOOL)value

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import <YapDatabase/YapDatabaseConnection.h>
@ -13,7 +13,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface YapDatabaseConnection (OWS)
- (BOOL)hasObjectForKey:(NSString *)key inCollection:(NSString *)collection;
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection;
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue;
- (double)doubleForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(double)defaultValue;
- (int)intForKey:(NSString *)key inCollection:(NSString *)collection;

@ -51,11 +51,6 @@ NS_ASSUME_NONNULL_BEGIN
return [self objectForKey:key inCollection:collection ofExpectedType:[NSString class]];
}
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection
{
return [self boolForKey:key inCollection:collection defaultValue:NO];
}
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue
{
NSNumber *_Nullable value = [self objectForKey:key inCollection:collection ofExpectedType:[NSNumber class]];

@ -12,7 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface YapDatabaseReadTransaction (OWS)
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection;
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue;
- (int)intForKey:(NSString *)key inCollection:(NSString *)collection;
- (nullable NSDate *)dateForKey:(NSString *)key inCollection:(NSString *)collection;

@ -36,14 +36,6 @@ NS_ASSUME_NONNULL_BEGIN
return [self objectForKey:key inCollection:collection ofExpectedType:[NSString class]];
}
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection
{
OWSAssertDebug(key.length > 0);
OWSAssertDebug(collection.length > 0);
return [self boolForKey:key inCollection:collection defaultValue:NO];
}
- (BOOL)boolForKey:(NSString *)key inCollection:(NSString *)collection defaultValue:(BOOL)defaultValue
{
OWSAssertDebug(key.length > 0);

Loading…
Cancel
Save