diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2020-03-16 10:00:43 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2020-03-17 10:51:06 +0100 |
| commit | 63e1af958dfa5c26d8a62505da3b76052ff440ef (patch) | |
| tree | ef1e94a561b803f54d72fd2302195a701394e164 /ios | |
| parent | fe5bae2cf61bd8238cb1bb27ff84052e1c6aa0bb (diff) | |
| download | mullvadvpn-63e1af958dfa5c26d8a62505da3b76052ff440ef.tar.xz mullvadvpn-63e1af958dfa5c26d8a62505da3b76052ff440ef.zip | |
Fix the edge case when the wrong key might be displayed on regenerate key + copy to clipboard data race
Diffstat (limited to 'ios')
| -rw-r--r-- | ios/MullvadVPN/WireguardKeysViewController.swift | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ios/MullvadVPN/WireguardKeysViewController.swift b/ios/MullvadVPN/WireguardKeysViewController.swift index 1bfc367f63..3ce6ac3e5f 100644 --- a/ios/MullvadVPN/WireguardKeysViewController.swift +++ b/ios/MullvadVPN/WireguardKeysViewController.swift @@ -110,12 +110,14 @@ class WireguardKeysViewController: UIViewController { animated: true) copyToPasteboardSubscriber = - Just(publicKey).cancellableDelay(for: .seconds(3), scheduler: DispatchQueue.main) - .sink(receiveValue: { [weak self] (publicKey) in + Just(()).cancellableDelay(for: .seconds(3), scheduler: DispatchQueue.main) + .sink(receiveValue: { [weak self] () in + guard let self = self, let publicKey = self.publicKey else { return } + let displayKey = publicKey .stringRepresentation(maxLength: kDisplayPublicKeyMaxLength) - self?.setPublicKeyTitle(string: displayKey, animated: true) + self.setPublicKeyTitle(string: displayKey, animated: true) }) } |
