From 6eb19a4dc619060b715b0ed87517ed8c4dafc556 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Thu, 2 Mar 2017 16:14:24 +0800 Subject: [PATCH] Polish code of long press to copy --- pass/Controllers/PasswordsViewController.swift | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index e503f6f..116b243 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -247,13 +247,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV Utils.alert(title: "Cannot Copy Password", message: "PGP Key is not set. Please set your PGP Key first.", controller: self, completion: nil) return } - let index = sections[indexPath.section].index + indexPath.row - let password: PasswordEntity - if searchController.isActive && searchController.searchBar.text != "" { - password = passwordsTableEntries[index].passwordEntity! - } else { - password = filteredPasswordsTableEntries[index].passwordEntity! - } + let password = getPasswordEntry(by: indexPath).passwordEntity! UIImpactFeedbackGenerator(style: .medium).impactOccurred() var passphrase = "" if Defaults[.isRememberPassphraseOn] && PasswordStore.shared.pgpKeyPassphrase != nil { @@ -284,7 +278,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV decryptedPassword = try passwordEntity.decrypt(passphrase: passphrase)! DispatchQueue.main.async { Utils.copyToPasteboard(textToCopy: decryptedPassword?.password) - SVProgressHUD.showSuccess(withStatus: "Password Copied") + SVProgressHUD.showSuccess(withStatus: "Password copied, and will be cleared in 45 seconds.") SVProgressHUD.dismiss(withDelay: 0.6) } } catch {