Fix crash on device linking failure

pull/70/head
Niels Andriesse 6 years ago
parent f53b00b36a
commit 661795bd00

@ -306,9 +306,14 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate, O
let linkingRequestMessage = DeviceLinkingUtilities.getLinkingRequestMessage(for: masterHexEncodedPublicKey) let linkingRequestMessage = DeviceLinkingUtilities.getLinkingRequestMessage(for: masterHexEncodedPublicKey)
ThreadUtil.enqueue(linkingRequestMessage) ThreadUtil.enqueue(linkingRequestMessage)
}.catch(on: DispatchQueue.main) { [weak self] _ in }.catch(on: DispatchQueue.main) { [weak self] _ in
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() TSAccountManager.sharedInstance().resetForReregistration()
}
guard let self = self else { return } 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) 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.present(alert, animated: true, completion: nil)
self.setUserInteractionEnabled(true) self.setUserInteractionEnabled(true)
} }

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

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

Loading…
Cancel
Save