summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-03-10 13:44:44 +0100
committerAndrej Mihajlov <and@mullvad.net>2020-03-17 10:51:06 +0100
commitfe5bae2cf61bd8238cb1bb27ff84052e1c6aa0bb (patch)
tree88a8802a08c7d3410e455b9eb1b4d2f59dbf5796 /ios
parenta410e8844369c6279aae0f56721bb45af5518210 (diff)
downloadmullvadvpn-fe5bae2cf61bd8238cb1bb27ff84052e1c6aa0bb.tar.xz
mullvadvpn-fe5bae2cf61bd8238cb1bb27ff84052e1c6aa0bb.zip
Use cancellableDelay in Account and WireGuard keys controllers
Diffstat (limited to 'ios')
-rw-r--r--ios/MullvadVPN/AccountViewController.swift10
-rw-r--r--ios/MullvadVPN/WireguardKeysViewController.swift8
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)
})
}