Fix crash on device linking failure

This commit is contained in:
Niels Andriesse 2019-11-22 09:36:16 +11:00
parent f53b00b36a
commit 661795bd00
3 changed files with 8 additions and 2 deletions

View file

@ -306,9 +306,14 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate, O
let linkingRequestMessage = DeviceLinkingUtilities.getLinkingRequestMessage(for: masterHexEncodedPublicKey)
ThreadUtil.enqueue(linkingRequestMessage)
}.catch(on: DispatchQueue.main) { [weak self] _ in
TSAccountManager.sharedInstance().resetForReregistration()
DispatchQueue.main.async {
// FIXME: For some reason resetForRegistration() complains about not being on the main queue
// without this (even though the catch closure should be executed on the main queue)
TSAccountManager.sharedInstance().resetForReregistration()
}
guard let self = self else { return }
let alert = UIAlertController(title: NSLocalizedString("Couldn't Link Device", comment: ""), message: NSLocalizedString("Please check your internet connection and try again", comment: ""), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", accessibilityIdentifier: nil, style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
self.setUserInteractionEnabled(true)
}

View file

@ -2670,3 +2670,4 @@
"Please check your internet connection and try again" = "Please check your internet connection and try again";
"Device Unlinked" = "Device Unlinked";
"Your device was unlinked successfully" = "Your device was unlinked successfully";
"Unnamed Device" = "Unnamed Device";

View file

@ -21,7 +21,7 @@ public final class DeviceLink : NSObject, NSCoding {
if let customDisplayName = UserDefaults.standard.string(forKey: "\(hexEncodedPublicKey)_display_name") {
return customDisplayName
} else {
return Mnemonic.encode(hexEncodedString: hexEncodedPublicKey.removing05PrefixIfNeeded()).split(separator: " ")[0..<3].joined(separator: " ")
return NSLocalizedString("Unnamed Device", comment: "")
}
}