Quick fix crash

pull/112/head
Niels Andriesse 5 years ago
parent 814d599dcc
commit 59b3491127

@ -155,7 +155,7 @@ final class DisplayNameVC : UIViewController {
return showError(title: NSLocalizedString("Please pick a shorter display name", comment: ""))
}
TSAccountManager.sharedInstance().didRegister()
OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: nil, success: { }, failure: { _ in }) // Try to save the user name but ignore the result
OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: nil, success: { }, failure: { _ in }, requiresSync: false) // Try to save the user name but ignore the result
let homeVC = HomeVC()
navigationController!.setViewControllers([ homeVC ], animated: true)
}

@ -152,6 +152,7 @@ final class HomeVC : UIViewController, UITableViewDataSource, UITableViewDelegat
// openGroupSuggestionSheet.modalTransitionStyle = .crossDissolve
// present(openGroupSuggestionSheet, animated: true, completion: nil)
// }
UserDefaults.standard.set(true, forKey: "hasLaunchedOnce")
}
override func viewWillDisappear(_ animated: Bool) {

@ -288,7 +288,7 @@ final class SettingsVC : UIViewController, AvatarViewHelperDelegate {
self?.present(alert, animated: true, completion: nil)
}
}
})
}, requiresSync: true)
}
}

@ -428,7 +428,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
@"profile update fails.")];
}];
});
}];
} requiresSync:NO];
}];
}

@ -177,7 +177,7 @@ public class OnboardingProfileViewController: OnboardingBaseViewController {
comment: "Error message shown when a profile update fails."))
})
}
})
}, requiresSync: false)
}
}

@ -339,7 +339,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
failure:^(NSError *error) {
// Ignore errors related to local profile.
resolve(@(1));
}];
}
requiresSync:YES];
}];
}

@ -224,9 +224,13 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
[AppReadiness runNowOrWhenAppDidBecomeReady:^{
if (!self.tsAccountManager.isRegisteredAndReady) {
return;
}
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
BOOL hasLaunchedOnce = [userDefaults boolForKey:@"hasLaunchedOnce"];
if (hasLaunchedOnce) { // FIXME: Quick and dirty workaround to not do this on initial launch
[self sendConfigurationSyncMessage_AppReady];
}
[self sendConfigurationSyncMessage_AppReady];
}];
}

@ -50,7 +50,8 @@ extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
- (void)updateLocalProfileName:(nullable NSString *)profileName
avatarImage:(nullable UIImage *)avatarImage
success:(void (^)(void))successBlock
failure:(void (^)(NSError *))failureBlock;
failure:(void (^)(NSError *))failureBlock
requiresSync:(BOOL)requiresSync;
- (BOOL)isProfileNameTooLong:(nullable NSString *)profileName;

@ -230,6 +230,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
avatarImage:(nullable UIImage *)avatarImage
success:(void (^)(void))successBlockParameter
failure:(void (^)(NSError *))failureBlockParameter
requiresSync:(BOOL)requiresSync
{
OWSAssertDebug(successBlockParameter);
OWSAssertDebug(failureBlockParameter);
@ -244,7 +245,9 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
//
// NOTE: We also inform the desktop in the failure case,
// since that _may have_ affected service state.
[[self.syncManager syncLocalContact] retainUntilComplete];
if (requiresSync) {
[[self.syncManager syncLocalContact] retainUntilComplete];
}
dispatch_async(dispatch_get_main_queue(), ^{
failureBlockParameter(error);
@ -256,7 +259,9 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
// We use a "self-only" contact sync to indicate to desktop
// that we've changed our profile and that it should do a
// profile fetch for "self".
[[self.syncManager syncLocalContact] retainUntilComplete];
if (requiresSync) {
[[self.syncManager syncLocalContact] retainUntilComplete];
}
dispatch_async(dispatch_get_main_queue(), ^{
successBlockParameter();

@ -243,7 +243,10 @@ NSString *const kLocalProfileUniqueId = @"kLocalProfileUniqueId";
// We populate an initial (empty) profile on launch of a new install, but until
// we have a registered account, syncing will fail (and there could not be any
// linked device to sync to at this point anyway).
if ([self.tsAccountManager isRegistered] && CurrentAppContext().isMainApp) {
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
BOOL hasLaunchedOnce = [userDefaults boolForKey:@"hasLaunchedOnce"];
if ([self.tsAccountManager isRegistered] && CurrentAppContext().isMainApp && hasLaunchedOnce) {
[[self.syncManager syncLocalContact] retainUntilComplete];
}

@ -3,7 +3,6 @@ import SignalMetadataKit
/// Base class for `LokiFileServerAPI` and `LokiPublicChatAPI`.
public class LokiDotNetAPI : NSObject {
public static var getAuthTokenPromises: [String:Promise<String>] = [:]
// MARK: Convenience
internal static let storage = OWSPrimaryStorage.shared()
@ -44,19 +43,13 @@ public class LokiDotNetAPI : NSObject {
}
internal static func getAuthToken(for server: String, in transaction: YapDatabaseReadWriteTransaction? = nil) -> Promise<String> {
if let promise = getAuthTokenPromises[server] { return promise }
if let token = getAuthTokenFromDatabase(for: server, in: transaction) {
return Promise.value(token)
} else {
let promise = requestNewAuthToken(for: server).then(on: DispatchQueue.global()) { submitAuthToken($0, for: server) }.map { token -> String in
return requestNewAuthToken(for: server).then(on: DispatchQueue.global()) { submitAuthToken($0, for: server) }.map { token -> String in
setAuthToken(for: server, to: token, in: transaction)
return token
}
promise.done { _ in
getAuthTokenPromises[server] = nil
}
getAuthTokenPromises[server] = promise
return promise
}
}

Loading…
Cancel
Save