mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Migrated a couple more preferences
This commit is contained in:
parent
c500d4c6ca
commit
cfb8f1615a
7 changed files with 23 additions and 57 deletions
|
@ -58,30 +58,28 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||
Environment.shared.audioSession.setup()
|
||||
SSKEnvironment.shared.reachabilityManager.setup()
|
||||
|
||||
if !Environment.shared.preferences.hasGeneratedThumbnails() {
|
||||
|
||||
// Disable the SAE until the main app has successfully completed launch process
|
||||
// at least once in the post-SAE world.
|
||||
OWSPreferences.setIsReadyForAppExtensions()
|
||||
|
||||
// Setup the UI
|
||||
self?.ensureRootViewController()
|
||||
|
||||
if Identity.userExists() {
|
||||
let appVersion: AppVersion = AppVersion.sharedInstance()
|
||||
GRDBStorage.shared.writeAsync { db in
|
||||
// Disable the SAE until the main app has successfully completed launch process
|
||||
// at least once in the post-SAE world.
|
||||
db[.isReadyForAppExtensions] = true
|
||||
|
||||
// If the device needs to sync config or the user updated to a new version
|
||||
if
|
||||
needsConfigSync || ( // TODO: 'needsConfigSync' logic for migrations
|
||||
(appVersion.lastAppVersion?.count ?? 0) > 0 &&
|
||||
appVersion.lastAppVersion != appVersion.currentAppVersion
|
||||
)
|
||||
{
|
||||
GRDBStorage.shared.write { db in
|
||||
if Identity.userExists(db) {
|
||||
let appVersion: AppVersion = AppVersion.sharedInstance()
|
||||
|
||||
// If the device needs to sync config or the user updated to a new version
|
||||
if
|
||||
needsConfigSync || (
|
||||
(appVersion.lastAppVersion?.count ?? 0) > 0 &&
|
||||
appVersion.lastAppVersion != appVersion.currentAppVersion
|
||||
)
|
||||
{
|
||||
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 preferencesKeyHasSavedThreadKey = "hasSavedThread"
|
||||
internal static let preferencesKeyHasSentAMessageKey = "User has sent a message"
|
||||
internal static let preferencesKeyIsReadyForAppExtensions = "isReadyForAppExtensions_5"
|
||||
|
||||
internal static let readReceiptManagerCollection = "OWSReadReceiptManagerCollection"
|
||||
internal static let readReceiptManagerAreReadReceiptsEnabled = "areReadReceiptsEnabled"
|
||||
|
|
|
@ -1420,6 +1420,7 @@ enum _003_YDBToGRDBMigration: Migration {
|
|||
.bool(forKey: SMKLegacy.userDefaultsHasHiddenMessageRequests)
|
||||
db[.hasSavedThread] = (legacyPreferences[SMKLegacy.preferencesKeyHasSavedThreadKey] 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")
|
||||
|
||||
|
|
|
@ -36,9 +36,6 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification;
|
|||
|
||||
#pragma mark - Specific Preferences
|
||||
|
||||
+ (BOOL)isReadyForAppExtensions;
|
||||
+ (void)setIsReadyForAppExtensions;
|
||||
|
||||
- (BOOL)hasSentAMessage;
|
||||
- (void)setHasSentAMessage:(BOOL)enabled;
|
||||
|
||||
|
@ -48,9 +45,6 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification;
|
|||
- (void)setIOSUpgradeNagDate:(NSDate *)value;
|
||||
- (nullable NSDate *)iOSUpgradeNagDate;
|
||||
|
||||
- (BOOL)hasGeneratedThumbnails;
|
||||
- (void)setHasGeneratedThumbnails:(BOOL)value;
|
||||
|
||||
- (BOOL)shouldShowUnidentifiedDeliveryIndicators;
|
||||
- (void)setShouldShowUnidentifiedDeliveryIndicators:(BOOL)value;
|
||||
|
||||
|
|
|
@ -12,11 +12,9 @@ NSString *const OWSPreferencesKeyCallKitEnabled = @"CallKitEnabled";
|
|||
NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled";
|
||||
NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress";
|
||||
NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView";
|
||||
NSString *const OWSPreferencesKeyHasGeneratedThumbnails = @"OWSPreferencesKeyHasGeneratedThumbnails";
|
||||
NSString *const OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators
|
||||
= @"OWSPreferencesKeyShouldShowUnidentifiedDeliveryIndicators";
|
||||
NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate";
|
||||
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
|
||||
NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySystemCallLogEnabled";
|
||||
|
||||
@implementation OWSPreferences
|
||||
|
@ -68,23 +66,6 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
|
|||
|
||||
#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
|
||||
{
|
||||
NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyHasDeclinedNoContactsView];
|
||||
|
@ -97,18 +78,6 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste
|
|||
[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
|
||||
{
|
||||
[self setValueForKey:OWSPreferencesKeyIOSUpgradeNagDate toValue:value];
|
||||
|
|
|
@ -49,6 +49,9 @@ public extension Setting.BoolKey {
|
|||
|
||||
/// A flag indicating whether the user has ever send a message
|
||||
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 {
|
||||
|
|
|
@ -112,7 +112,7 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
|
|||
// 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
|
||||
// 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(
|
||||
appSpecificSingletonBlock: {
|
||||
|
|
Loading…
Reference in a new issue