Put PasswordStore as instance in controllers

This commit is contained in:
Bob Sun 2017-03-16 22:39:03 -07:00
parent d338e725d5
commit d2cff20131
12 changed files with 67 additions and 55 deletions

View file

@ -13,6 +13,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
var needRefresh = false
var indicatorLabel: UILabel!
var indicator: UIActivityIndicatorView!
let passwordStore = PasswordStore.shared
override func viewDidLoad() {
navigationItemTitle = "About Repository"
@ -57,20 +58,20 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
numberFormatter.numberStyle = NumberFormatter.Style.decimal
let fm = FileManager.default
let passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData(withDir: false)
let passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(withDir: false)
let numberOfPasswords = numberFormatter.string(from: NSNumber(value: passwordEntities.count))!
var size = UInt64(0)
do {
if fm.fileExists(atPath: PasswordStore.shared.storeURL.path) {
size = try fm.allocatedSizeOfDirectoryAtURL(directoryURL: PasswordStore.shared.storeURL)
if fm.fileExists(atPath: self.passwordStore.storeURL.path) {
size = try fm.allocatedSizeOfDirectoryAtURL(directoryURL: self.passwordStore.storeURL)
}
} catch {
print(error)
}
let sizeOfRepository = ByteCountFormatter.string(fromByteCount: Int64(size), countStyle: ByteCountFormatter.CountStyle.file)
let numberOfCommits = PasswordStore.shared.storeRepository?.numberOfCommits(inCurrentBranch: NSErrorPointer(nilLiteral: ())) ?? 0
let numberOfCommits = self.passwordStore.storeRepository?.numberOfCommits(inCurrentBranch: NSErrorPointer(nilLiteral: ())) ?? 0
let numberOfCommitsString = numberFormatter.string(from: NSNumber(value: numberOfCommits))!
@ -79,7 +80,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
self?.tableData = [
// section 0
[[.style: CellDataStyle.value1, .accessoryType: type, .title: "Passwords", .detailText: numberOfPasswords],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Size", .detailText: sizeOfRepository], [.style: CellDataStyle.value1, .accessoryType: type, .title: "Unsynced", .detailText: String(PasswordStore.shared.getNumberOfUnsyncedPasswords())],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Size", .detailText: sizeOfRepository], [.style: CellDataStyle.value1, .accessoryType: type, .title: "Unsynced", .detailText: String(self?.passwordStore.getNumberOfUnsyncedPasswords() ?? 0)],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Last Synced", .detailText: Utils.getLastUpdatedTimeString()],
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Commits", .detailText: numberOfCommitsString],
[.title: "Commit Logs", .action: "segue", .link: "showCommitLogsSegue"],

View file

@ -13,6 +13,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
var password: Password?
var tempContent: String = ""
let passwordStore = PasswordStore.shared
override func viewDidLoad() {
tableData = [
@ -27,7 +28,7 @@ class AddPasswordTableViewController: PasswordEditorTableViewController {
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
if identifier == "saveAddPasswordSegue" {
// check PGP key
if PasswordStore.shared.privateKey == nil {
if passwordStore.privateKey == nil {
let alertTitle = "Cannot Add Password"
let alertMessage = "PGP Key is not set. Please set your PGP Key first."
Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil)

View file

@ -13,6 +13,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
@IBOutlet weak var eraseDataTableViewCell: UITableViewCell!
@IBOutlet weak var discardChangesTableViewCell: UITableViewCell!
let passwordStore = PasswordStore.shared
override func viewDidLoad() {
super.viewDidLoad()
@ -24,7 +25,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
let alert = UIAlertController(title: "Erase Password Store Data?", message: "This will delete all local data and settings. Password store data on your remote server will not be affected.", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Erase Password Data", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in
SVProgressHUD.show(withStatus: "Erasing ...")
PasswordStore.shared.erase()
self.passwordStore.erase()
NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreErased")))
self.navigationController!.popViewController(animated: true)
SVProgressHUD.showSuccess(withStatus: "Done")
@ -40,7 +41,7 @@ class AdvancedSettingsTableViewController: UITableViewController {
SVProgressHUD.show(withStatus: "Resetting ...")
DispatchQueue.main.async {
do {
let numberDiscarded = try PasswordStore.shared.reset()
let numberDiscarded = try self.passwordStore.reset()
if numberDiscarded > 0 {
NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreChangeDiscarded")))
}

View file

@ -11,10 +11,11 @@ import ObjectiveGit
class CommitLogsTableViewController: UITableViewController {
var commits: [GTCommit] = []
let passwordStore = PasswordStore.shared
override func viewDidLoad() {
super.viewDidLoad()
commits = PasswordStore.shared.getRecentCommits(count: 20)
commits = passwordStore.getRecentCommits(count: 20)
navigationItem.title = "Recent Commit Logs"
navigationController!.navigationBar.topItem!.title = "About"
}

View file

@ -10,6 +10,7 @@ import UIKit
import SwiftyUserDefaults
class GeneralSettingsTableViewController: BasicStaticTableViewController {
let passwordStore = PasswordStore.shared
let hideUnknownSwitch: UISwitch = {
let uiSwitch = UISwitch()
@ -177,7 +178,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
func rememberPassphraseSwitchAction(_ sender: Any?) {
Defaults[.isRememberPassphraseOn] = rememberPassphraseSwitch.isOn
if rememberPassphraseSwitch.isOn == false {
PasswordStore.shared.pgpKeyPassphrase = nil
passwordStore.pgpKeyPassphrase = nil
}
}

View file

@ -15,6 +15,7 @@ class GitServerSettingTableViewController: UITableViewController {
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var authSSHKeyCell: UITableViewCell!
@IBOutlet weak var authPasswordCell: UITableViewCell!
let passwordStore = PasswordStore.shared
var password: String?
var authenticationMethod = Defaults[.gitRepositoryAuthenticationMethod]
@ -41,7 +42,7 @@ class GitServerSettingTableViewController: UITableViewController {
gitRepositoryURLTextField.text = url.absoluteString
}
usernameTextField.text = Defaults[.gitRepositoryUsername]
password = PasswordStore.shared.gitRepositoryPassword
password = passwordStore.gitRepositoryPassword
authenticationMethod = Defaults[.gitRepositoryAuthenticationMethod]
// Grey out ssh option if ssh_key and ssh_key.pub are not present

View file

@ -13,12 +13,13 @@ class PGPKeyArmorSettingTableViewController: UITableViewController {
@IBOutlet weak var armorPublicKeyTextView: UITextView!
@IBOutlet weak var armorPrivateKeyTextView: UITextView!
var pgpPassphrase: String?
let passwordStore = PasswordStore.shared
override func viewDidLoad() {
super.viewDidLoad()
armorPublicKeyTextView.text = Defaults[.pgpPublicKeyArmor]
armorPrivateKeyTextView.text = Defaults[.pgpPrivateKeyArmor]
pgpPassphrase = PasswordStore.shared.pgpKeyPassphrase
pgpPassphrase = passwordStore.pgpKeyPassphrase
}
private func createSavePassphraseAlert() -> UIAlertController {

View file

@ -14,13 +14,14 @@ class PGPKeySettingTableViewController: UITableViewController {
@IBOutlet weak var pgpPublicKeyURLTextField: UITextField!
@IBOutlet weak var pgpPrivateKeyURLTextField: UITextField!
var pgpPassphrase: String?
let passwordStore = PasswordStore.shared
override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = UITableViewAutomaticDimension
pgpPublicKeyURLTextField.text = Defaults[.pgpPublicKeyURL]?.absoluteString
pgpPrivateKeyURLTextField.text = Defaults[.pgpPrivateKeyURL]?.absoluteString
pgpPassphrase = PasswordStore.shared.pgpKeyPassphrase
pgpPassphrase = passwordStore.pgpKeyPassphrase
}
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {

View file

@ -18,6 +18,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
var passwordImage: UIImage?
var oneTimePasswordIndexPath : IndexPath?
var shouldPopCurrentView = false
let passwordStore = PasswordStore.shared
let indicatorLable: UILabel = {
let label = UILabel(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 21))
@ -91,8 +92,8 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
}
var passphrase = ""
if Defaults[.isRememberPassphraseOn] && PasswordStore.shared.pgpKeyPassphrase != nil {
passphrase = PasswordStore.shared.pgpKeyPassphrase!
if Defaults[.isRememberPassphraseOn] && self.passwordStore.pgpKeyPassphrase != nil {
passphrase = self.passwordStore.pgpKeyPassphrase!
self.decryptThenShowPassword(passphrase: passphrase)
} else {
let alert = UIAlertController(title: "Passphrase", message: "Please fill in the passphrase of your PGP secret key.", preferredStyle: UIAlertControllerStyle.alert)
@ -114,7 +115,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
func decryptThenShowPassword(passphrase: String) {
if Defaults[.isRememberPassphraseOn] {
PasswordStore.shared.pgpKeyPassphrase = passphrase
self.passwordStore.pgpKeyPassphrase = passphrase
}
DispatchQueue.global(qos: .userInitiated).async {
do {
@ -188,14 +189,14 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
if self.password!.changed {
SVProgressHUD.show(withStatus: "Saving")
DispatchQueue.global(qos: .userInitiated).async {
PasswordStore.shared.update(passwordEntity: self.passwordEntity!, password: self.password!, progressBlock: { progress in
self.passwordStore.update(passwordEntity: self.passwordEntity!, password: self.password!, progressBlock: { progress in
DispatchQueue.main.async {
SVProgressHUD.showProgress(progress, status: "Encrypting")
}
})
DispatchQueue.main.async {
self.passwordEntity!.synced = false
PasswordStore.shared.saveUpdated(passwordEntity: self.passwordEntity!)
self.passwordStore.saveUpdated(passwordEntity: self.passwordEntity!)
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
self.setTableData()
self.tableView.reloadData()
@ -296,7 +297,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
self?.tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
let imageData = UIImageJPEGRepresentation(image, 1)
if let entity = self?.passwordEntity {
PasswordStore.shared.updateImage(passwordEntity: entity, image: imageData)
self?.passwordStore.updateImage(passwordEntity: entity, image: imageData)
}
case .failure(let error):
print(error)
@ -373,7 +374,7 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
footerLabel.numberOfLines = 0
footerLabel.font = UIFont.preferredFont(forTextStyle: .footnote)
footerLabel.textColor = UIColor.gray
let dateString = PasswordStore.shared.getLatestUpdateInfo(filename: (passwordEntity?.path)!)
let dateString = self.passwordStore.getLatestUpdateInfo(filename: (passwordEntity?.path)!)
footerLabel.text = "Last Updated: \(dateString)"
view.addSubview(footerLabel)
return view

View file

@ -25,6 +25,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
private var passwordsTableEntries: [PasswordsTableEntry] = []
private var filteredPasswordsTableEntries: [PasswordsTableEntry] = []
private var parentPasswordEntity: PasswordEntity? = nil
let passwordStore = PasswordStore.shared
private var tapTabBarTime: TimeInterval = 0
@ -61,9 +62,9 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
filteredPasswordsTableEntries.removeAll()
var passwordEntities = [PasswordEntity]()
if Defaults[.isShowFolderOn] {
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData(parent: parent)
passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(parent: parent)
} else {
passwordEntities = PasswordStore.shared.fetchPasswordEntityCoreData(withDir: false)
passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(withDir: false)
}
passwordsTableEntries = passwordEntities.map {
@ -82,7 +83,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
SVProgressHUD.show(withStatus: "Saving")
DispatchQueue.global(qos: .userInitiated).async {
do {
try PasswordStore.shared.add(password: controller.password!, progressBlock: { progress in
try self.passwordStore.add(password: controller.password!, progressBlock: { progress in
DispatchQueue.main.async {
SVProgressHUD.showProgress(progress, status: "Encrypting")
}
@ -107,26 +108,26 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.show(withStatus: "Sync Password Store")
let numberOfUnsyncedPasswords = PasswordStore.shared.getNumberOfUnsyncedPasswords()
let numberOfUnsyncedPasswords = self.passwordStore.getNumberOfUnsyncedPasswords()
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
do {
try PasswordStore.shared.pullRepository(transferProgressBlock: {(git_transfer_progress, stop) in
try self.passwordStore.pullRepository(transferProgressBlock: {(git_transfer_progress, stop) in
DispatchQueue.main.async {
SVProgressHUD.showProgress(Float(git_transfer_progress.pointee.received_objects)/Float(git_transfer_progress.pointee.total_objects), status: "Pull Remote Repository")
}
})
if numberOfUnsyncedPasswords > 0 {
try PasswordStore.shared.pushRepository(transferProgressBlock: {(current, total, bytes, stop) in
try self.passwordStore.pushRepository(transferProgressBlock: {(current, total, bytes, stop) in
DispatchQueue.main.async {
SVProgressHUD.showProgress(Float(current)/Float(total), status: "Push Remote Repository")
}
})
}
DispatchQueue.main.async {
PasswordStore.shared.updatePasswordEntityCoreData()
self.passwordStore.updatePasswordEntityCoreData()
self.initPasswordsTableEntries(parent: nil)
self.reloadTableView(data: self.passwordsTableEntries)
PasswordStore.shared.setAllSynced()
self.passwordStore.setAllSynced()
self.setNavigationItemTitle()
Defaults[.lastUpdatedTime] = Date()
Defaults[.gitRepositoryPasswordAttempts] = 0
@ -283,15 +284,15 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
}
func copyToPasteboard(from indexPath: IndexPath) {
guard PasswordStore.shared.privateKey != nil else {
guard self.passwordStore.privateKey != nil else {
Utils.alert(title: "Cannot Copy Password", message: "PGP Key is not set. Please set your PGP Key first.", controller: self, completion: nil)
return
}
let password = getPasswordEntry(by: indexPath).passwordEntity!
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
var passphrase = ""
if Defaults[.isRememberPassphraseOn] && PasswordStore.shared.pgpKeyPassphrase != nil {
passphrase = PasswordStore.shared.pgpKeyPassphrase!
if Defaults[.isRememberPassphraseOn] && self.passwordStore.pgpKeyPassphrase != nil {
passphrase = self.passwordStore.pgpKeyPassphrase!
self.decryptThenCopyPassword(passwordEntity: password, passphrase: passphrase)
} else {
let alert = UIAlertController(title: "Passphrase", message: "Please fill in the passphrase of your PGP secret key.", preferredStyle: UIAlertControllerStyle.alert)
@ -366,7 +367,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
} else {
title = "Password Store"
}
let numberOfUnsynced = PasswordStore.shared.getNumberOfUnsyncedPasswords()
let numberOfUnsynced = self.passwordStore.getNumberOfUnsyncedPasswords()
if numberOfUnsynced == 0 {
navigationItem.title = "\(title)"
} else {
@ -387,7 +388,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
if identifier == "showPasswordDetail" {
guard PasswordStore.shared.privateKey != nil else {
guard self.passwordStore.privateKey != nil else {
Utils.alert(title: "Cannot Show Password", message: "PGP Key is not set. Please set your PGP Key first.", controller: self, completion: nil)
if let s = sender as? UITableViewCell {
let selectedIndexPath = tableView.indexPath(for: s)!

View file

@ -25,6 +25,7 @@ class SettingsTableViewController: UITableViewController {
@IBOutlet weak var touchIDTableViewCell: UITableViewCell!
@IBOutlet weak var passcodeTableViewCell: UITableViewCell!
@IBOutlet weak var passwordRepositoryTableViewCell: UITableViewCell!
let passwordStore = PasswordStore.shared
@IBAction func cancelPGPKey(segue: UIStoryboardSegue) {
}
@ -33,7 +34,7 @@ class SettingsTableViewController: UITableViewController {
if let controller = segue.source as? PGPKeySettingTableViewController {
Defaults[.pgpPrivateKeyURL] = URL(string: controller.pgpPrivateKeyURLTextField.text!)
Defaults[.pgpPublicKeyURL] = URL(string: controller.pgpPublicKeyURLTextField.text!)
PasswordStore.shared.pgpKeyPassphrase = controller.pgpPassphrase
self.passwordStore.pgpKeyPassphrase = controller.pgpPassphrase
Defaults[.pgpKeySource] = "url"
SVProgressHUD.setDefaultMaskType(.black)
@ -41,10 +42,10 @@ class SettingsTableViewController: UITableViewController {
SVProgressHUD.show(withStatus: "Fetching PGP Key")
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
do {
try PasswordStore.shared.initPGPKey(from: Defaults[.pgpPublicKeyURL]!, keyType: .public)
try PasswordStore.shared.initPGPKey(from: Defaults[.pgpPrivateKeyURL]!, keyType: .secret)
try self.passwordStore.initPGPKey(from: Defaults[.pgpPublicKeyURL]!, keyType: .public)
try self.passwordStore.initPGPKey(from: Defaults[.pgpPrivateKeyURL]!, keyType: .secret)
DispatchQueue.main.async {
self.pgpKeyTableViewCell.detailTextLabel?.text = PasswordStore.shared.pgpKeyID
self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpKeyID
SVProgressHUD.showSuccess(withStatus: "Success")
SVProgressHUD.dismiss(withDelay: 1)
Utils.alert(title: "Rememver to Remove the Key", message: "Remember to remove the key from the server.", controller: self, completion: nil)
@ -60,7 +61,7 @@ class SettingsTableViewController: UITableViewController {
} else if let controller = segue.source as? PGPKeyArmorSettingTableViewController {
Defaults[.pgpKeySource] = "armor"
PasswordStore.shared.pgpKeyPassphrase = controller.pgpPassphrase
self.passwordStore.pgpKeyPassphrase = controller.pgpPassphrase
if Defaults[.isRememberPassphraseOn] {
Utils.addPasswordToKeychain(name: "pgpKeyPassphrase", password: controller.pgpPassphrase!)
}
@ -73,10 +74,10 @@ class SettingsTableViewController: UITableViewController {
SVProgressHUD.show(withStatus: "Fetching PGP Key")
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
do {
try PasswordStore.shared.initPGPKey(with: controller.armorPublicKeyTextView.text, keyType: .public)
try PasswordStore.shared.initPGPKey(with: controller.armorPrivateKeyTextView.text, keyType: .secret)
try self.passwordStore.initPGPKey(with: controller.armorPublicKeyTextView.text, keyType: .public)
try self.passwordStore.initPGPKey(with: controller.armorPrivateKeyTextView.text, keyType: .secret)
DispatchQueue.main.async {
self.pgpKeyTableViewCell.detailTextLabel?.text = PasswordStore.shared.pgpKeyID
self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpKeyID
SVProgressHUD.showSuccess(withStatus: "Success")
SVProgressHUD.dismiss(withDelay: 1)
}
@ -105,8 +106,8 @@ class SettingsTableViewController: UITableViewController {
Defaults[.gitRepositoryURL]!.absoluteString != gitRepostiroyURL ||
auth != Defaults[.gitRepositoryAuthenticationMethod] ||
username != Defaults[.gitRepositoryUsername] ||
password != PasswordStore.shared.gitRepositoryPassword ||
PasswordStore.shared.repositoryExisted() == false {
password != self.passwordStore.gitRepositoryPassword ||
self.passwordStore.repositoryExisted() == false {
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.light)
@ -128,7 +129,7 @@ class SettingsTableViewController: UITableViewController {
let dispatchQueue = DispatchQueue.global(qos: .userInitiated)
dispatchQueue.async {
do {
try PasswordStore.shared.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
try self.passwordStore.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
credential: gitCredential,
transferProgressBlock:{ (git_transfer_progress, stop) in
DispatchQueue.main.async {
@ -141,7 +142,7 @@ class SettingsTableViewController: UITableViewController {
}
})
DispatchQueue.main.async {
PasswordStore.shared.updatePasswordEntityCoreData()
self.passwordStore.updatePasswordEntityCoreData()
Defaults[.lastUpdatedTime] = Date()
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
@ -187,7 +188,7 @@ class SettingsTableViewController: UITableViewController {
}
private func setPGPKeyTableViewCellDetailText() {
if let pgpKeyID = PasswordStore.shared.pgpKeyID {
if let pgpKeyID = self.passwordStore.pgpKeyID {
pgpKeyTableViewCell.detailTextLabel?.text = pgpKeyID
} else {
pgpKeyTableViewCell.detailTextLabel?.text = "Not Set"
@ -224,7 +225,7 @@ class SettingsTableViewController: UITableViewController {
}))
alert.addTextField(configurationHandler: {(textField: UITextField!) in
textField.text = PasswordStore.shared.gitRepositoryPassword
textField.text = self.passwordStore.gitRepositoryPassword
textField.isSecureTextEntry = true
})
@ -337,9 +338,9 @@ class SettingsTableViewController: UITableViewController {
DispatchQueue.main.async {
PasswordStore.shared.initPGPKeys()
self.passwordStore.initPGPKeys()
let key: PGPKey = PasswordStore.shared.getPgpPrivateKey()
let key: PGPKey = self.passwordStore.getPgpPrivateKey()
Defaults[.pgpKeySource] = "file"
if (key.isEncrypted) {
@ -348,7 +349,7 @@ class SettingsTableViewController: UITableViewController {
}
SVProgressHUD.dismiss()
self.pgpKeyTableViewCell.detailTextLabel?.text = PasswordStore.shared.pgpKeyID
self.pgpKeyTableViewCell.detailTextLabel?.text = self.passwordStore.pgpKeyID
}
}

View file

@ -19,6 +19,7 @@ class LabelTableViewCell: UITableViewCell {
@IBOutlet weak var contentLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
let passwordStore = PasswordStore.shared
var isPasswordCell = false
var isURLCell = false
@ -126,10 +127,10 @@ class LabelTableViewCell: UITableViewCell {
// commit
if password.changed {
DispatchQueue.global(qos: .userInitiated).async {
PasswordStore.shared.update(passwordEntity: passwordEntity, password: password, progressBlock: {_ in })
self.passwordStore.update(passwordEntity: passwordEntity, password: password, progressBlock: {_ in })
DispatchQueue.main.async {
passwordEntity.synced = false
PasswordStore.shared.saveUpdated(passwordEntity: passwordEntity)
self.passwordStore.saveUpdated(passwordEntity: passwordEntity)
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
// reload so that the "unsynced" symbol could be added
self.passwordTableView?.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: UITableViewRowAnimation.automatic)