diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2020-03-10 13:44:44 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2020-03-17 10:51:06 +0100 |
| commit | fe5bae2cf61bd8238cb1bb27ff84052e1c6aa0bb (patch) | |
| tree | 88a8802a08c7d3410e455b9eb1b4d2f59dbf5796 | |
| parent | a410e8844369c6279aae0f56721bb45af5518210 (diff) | |
| download | mullvadvpn-fe5bae2cf61bd8238cb1bb27ff84052e1c6aa0bb.tar.xz mullvadvpn-fe5bae2cf61bd8238cb1bb27ff84052e1c6aa0bb.zip | |
Use cancellableDelay in Account and WireGuard keys controllers
| -rw-r--r-- | ios/MullvadVPN/AccountViewController.swift | 10 | ||||
| -rw-r--r-- | ios/MullvadVPN/WireguardKeysViewController.swift | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/ios/MullvadVPN/AccountViewController.swift b/ios/MullvadVPN/AccountViewController.swift index 6456140cf0..58a35875cc 100644 --- a/ios/MullvadVPN/AccountViewController.swift +++ b/ios/MullvadVPN/AccountViewController.swift @@ -64,16 +64,18 @@ class AccountViewController: UIViewController { } @IBAction func copyAccountToken() { - UIPasteboard.general.string = Account.shared.token + let accountToken = Account.shared.token + + UIPasteboard.general.string = accountToken accountTokenButton.setTitle( NSLocalizedString("COPIED TO PASTEBOARD!", comment: ""), for: .normal) copyToPasteboardSubscriber = - Just(()).delay(for: .seconds(3), scheduler: DispatchQueue.main) - .sink(receiveValue: { _ in - self.accountTokenButton.setTitle(Account.shared.token, for: .normal) + Just(accountToken).cancellableDelay(for: .seconds(3), scheduler: DispatchQueue.main) + .sink(receiveValue: { [weak self] (accountToken) in + self?.accountTokenButton.setTitle(accountToken, for: .normal) }) } diff --git a/ios/MullvadVPN/WireguardKeysViewController.swift b/ios/MullvadVPN/WireguardKeysViewController.swift index 881200c963..1bfc367f63 100644 --- a/ios/MullvadVPN/WireguardKeysViewController.swift +++ b/ios/MullvadVPN/WireguardKeysViewController.swift @@ -110,14 +110,12 @@ class WireguardKeysViewController: UIViewController { animated: true) copyToPasteboardSubscriber = - Just(()).delay(for: .seconds(3), scheduler: DispatchQueue.main) - .sink(receiveValue: { [weak self] _ in - guard let self = self, let publicKey = self.publicKey else { return } - + Just(publicKey).cancellableDelay(for: .seconds(3), scheduler: DispatchQueue.main) + .sink(receiveValue: { [weak self] (publicKey) in let displayKey = publicKey .stringRepresentation(maxLength: kDisplayPublicKeyMaxLength) - self.setPublicKeyTitle(string: displayKey, animated: true) + self?.setPublicKeyTitle(string: displayKey, animated: true) }) } |
