From 661795bd0003ac4a54659076da1ae47f3d0b2a44 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 22 Nov 2019 09:36:16 +1100 Subject: [PATCH] Fix crash on device linking failure --- Signal/src/Loki/Onboarding/SeedVC.swift | 7 ++++++- Signal/translations/en.lproj/Localizable.strings | 1 + .../src/Loki/API/Multi Device/DeviceLink.swift | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Signal/src/Loki/Onboarding/SeedVC.swift b/Signal/src/Loki/Onboarding/SeedVC.swift index 9cc4838a6..18947bd2f 100644 --- a/Signal/src/Loki/Onboarding/SeedVC.swift +++ b/Signal/src/Loki/Onboarding/SeedVC.swift @@ -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) } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 525f1f3cb..d15a68680 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -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"; diff --git a/SignalServiceKit/src/Loki/API/Multi Device/DeviceLink.swift b/SignalServiceKit/src/Loki/API/Multi Device/DeviceLink.swift index 3cf302e7b..733bbf3b9 100644 --- a/SignalServiceKit/src/Loki/API/Multi Device/DeviceLink.swift +++ b/SignalServiceKit/src/Loki/API/Multi Device/DeviceLink.swift @@ -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: "") } }