Migrated a couple more preferences

pull/612/head
Morgan Pretty 3 years ago
parent c500d4c6ca
commit cfb8f1615a

@ -58,30 +58,28 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
Environment.shared.audioSession.setup() Environment.shared.audioSession.setup()
SSKEnvironment.shared.reachabilityManager.setup() SSKEnvironment.shared.reachabilityManager.setup()
if !Environment.shared.preferences.hasGeneratedThumbnails() { GRDBStorage.shared.writeAsync { db in
// Disable the SAE until the main app has successfully completed launch process // Disable the SAE until the main app has successfully completed launch process
// at least once in the post-SAE world. // at least once in the post-SAE world.
OWSPreferences.setIsReadyForAppExtensions() db[.isReadyForAppExtensions] = true
// Setup the UI
self?.ensureRootViewController()
if Identity.userExists() { if Identity.userExists(db) {
let appVersion: AppVersion = AppVersion.sharedInstance() let appVersion: AppVersion = AppVersion.sharedInstance()
// If the device needs to sync config or the user updated to a new version // If the device needs to sync config or the user updated to a new version
if if
needsConfigSync || ( // TODO: 'needsConfigSync' logic for migrations needsConfigSync || (
(appVersion.lastAppVersion?.count ?? 0) > 0 && (appVersion.lastAppVersion?.count ?? 0) > 0 &&
appVersion.lastAppVersion != appVersion.currentAppVersion appVersion.lastAppVersion != appVersion.currentAppVersion
) )
{ {
GRDBStorage.shared.write { db in
try MessageSender.syncConfiguration(db, forceSyncNow: true).retainUntilComplete() try MessageSender.syncConfiguration(db, forceSyncNow: true).retainUntilComplete()
} }
} }
} }
// Setup the UI
self?.ensureRootViewController()
} }
) )

@ -59,6 +59,7 @@ public enum SMKLegacy {
internal static let preferencesKeyNotificationSoundInForeground = "NotificationSoundInForeground" internal static let preferencesKeyNotificationSoundInForeground = "NotificationSoundInForeground"
internal static let preferencesKeyHasSavedThreadKey = "hasSavedThread" internal static let preferencesKeyHasSavedThreadKey = "hasSavedThread"
internal static let preferencesKeyHasSentAMessageKey = "User has sent a message" internal static let preferencesKeyHasSentAMessageKey = "User has sent a message"
internal static let preferencesKeyIsReadyForAppExtensions = "isReadyForAppExtensions_5"
internal static let readReceiptManagerCollection = "OWSReadReceiptManagerCollection" internal static let readReceiptManagerCollection = "OWSReadReceiptManagerCollection"
internal static let readReceiptManagerAreReadReceiptsEnabled = "areReadReceiptsEnabled" internal static let readReceiptManagerAreReadReceiptsEnabled = "areReadReceiptsEnabled"

@ -1420,6 +1420,7 @@ enum _003_YDBToGRDBMigration: Migration {
.bool(forKey: SMKLegacy.userDefaultsHasHiddenMessageRequests) .bool(forKey: SMKLegacy.userDefaultsHasHiddenMessageRequests)
db[.hasSavedThread] = (legacyPreferences[SMKLegacy.preferencesKeyHasSavedThreadKey] as? Bool == true) db[.hasSavedThread] = (legacyPreferences[SMKLegacy.preferencesKeyHasSavedThreadKey] as? Bool == true)
db[.hasSentAMessage] = (legacyPreferences[SMKLegacy.preferencesKeyHasSentAMessageKey] as? Bool == true) db[.hasSentAMessage] = (legacyPreferences[SMKLegacy.preferencesKeyHasSentAMessageKey] as? Bool == true)
db[.isReadyForAppExtensions] = CurrentAppContext().appUserDefaults().bool(forKey: SMKLegacy.preferencesKeyIsReadyForAppExtensions)
print("RAWR [\(Date().timeIntervalSince1970)] - Process preferences inserts - End") print("RAWR [\(Date().timeIntervalSince1970)] - Process preferences inserts - End")

@ -36,9 +36,6 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification;
#pragma mark - Specific Preferences #pragma mark - Specific Preferences
+ (BOOL)isReadyForAppExtensions;
+ (void)setIsReadyForAppExtensions;
- (BOOL)hasSentAMessage; - (BOOL)hasSentAMessage;
- (void)setHasSentAMessage:(BOOL)enabled; - (void)setHasSentAMessage:(BOOL)enabled;
@ -48,9 +45,6 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification;
- (void)setIOSUpgradeNagDate:(NSDate *)value; - (void)setIOSUpgradeNagDate:(NSDate *)value;
- (nullable NSDate *)iOSUpgradeNagDate; - (nullable NSDate *)iOSUpgradeNagDate;
- (BOOL)hasGeneratedThumbnails;
- (void)setHasGeneratedThumbnails:(BOOL)value;
- (BOOL)shouldShowUnidentifiedDeliveryIndicators; - (BOOL)shouldShowUnidentifiedDeliveryIndicators;
- (void)setShouldShowUnidentifiedDeliveryIndicators:(BOOL)value; - (void)setShouldShowUnidentifiedDeliveryIndicators:(BOOL)value;

@ -12,11 +12,9 @@ NSString *const OWSPreferencesKeyCallKitEnabled = @"CallKitEnabled";
NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled"; NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled";
NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress"; NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress";
NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView"; NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView";
NSString *const OWSPreferencesKeyHasGeneratedThumbnails = @"OWSPreferencesKeyHasGeneratedThumbnails";
NSString *const OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators NSString *const OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators
= @"OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators"; = @"OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators";
NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate"; NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySystemCallLogEnabled"; NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySystemCallLogEnabled";
@implementation OWSPreferences @implementation OWSPreferences
@ -68,23 +66,6 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
#pragma mark - Specific Preferences #pragma mark - Specific Preferences
+ (BOOL)isReadyForAppExtensions
{
NSNumber *preference = [NSUserDefaults.appUserDefaults objectForKey:OWSPreferencesKey_IsReadyForAppExtensions];
if (preference) {
return [preference boolValue];
} else {
return NO;
}
}
+ (void)setIsReadyForAppExtensions
{
[NSUserDefaults.appUserDefaults setObject:@(YES) forKey:OWSPreferencesKey_IsReadyForAppExtensions];
[NSUserDefaults.appUserDefaults synchronize];
}
- (BOOL)hasDeclinedNoContactsView - (BOOL)hasDeclinedNoContactsView
{ {
NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyHasDeclinedNoContactsView]; NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyHasDeclinedNoContactsView];
@ -97,18 +78,6 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
[self setValueForKey:OWSPreferencesKeyHasDeclinedNoContactsView toValue:@(value)]; [self setValueForKey:OWSPreferencesKeyHasDeclinedNoContactsView toValue:@(value)];
} }
- (BOOL)hasGeneratedThumbnails
{
NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyHasGeneratedThumbnails];
// Default to NO.
return preference ? [preference boolValue] : NO;
}
- (void)setHasGeneratedThumbnails:(BOOL)value
{
[self setValueForKey:OWSPreferencesKeyHasGeneratedThumbnails toValue:@(value)];
}
- (void)setIOSUpgradeNagDate:(NSDate *)value - (void)setIOSUpgradeNagDate:(NSDate *)value
{ {
[self setValueForKey:OWSPreferencesKeyIOSUpgradeNagDate toValue:value]; [self setValueForKey:OWSPreferencesKeyIOSUpgradeNagDate toValue:value];

@ -49,6 +49,9 @@ public extension Setting.BoolKey {
/// A flag indicating whether the user has ever send a message /// A flag indicating whether the user has ever send a message
static let hasSentAMessage: Setting.BoolKey = "hasSentAMessageKey" static let hasSentAMessage: Setting.BoolKey = "hasSentAMessageKey"
/// A flag indicating whether the app is ready for app extensions to run
static let isReadyForAppExtensions: Setting.BoolKey = "isReadyForAppExtensions"
} }
public extension Setting.StringKey { public extension Setting.StringKey {

@ -112,7 +112,7 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
// this path should never occur. However, the service does have our push token // this path should never occur. However, the service does have our push token
// so it is possible that could change in the future. If it does, do nothing // so it is possible that could change in the future. If it does, do nothing
// and don't disturb the user. Messages will be processed when they open the app. // and don't disturb the user. Messages will be processed when they open the app.
guard OWSPreferences.isReadyForAppExtensions() else { return completeSilenty() } guard GRDBStorage.shared[.isReadyForAppExtensions] else { return completeSilenty() }
AppSetup.setupEnvironment( AppSetup.setupEnvironment(
appSpecificSingletonBlock: { appSpecificSingletonBlock: {

Loading…
Cancel
Save