Polish the logic about updating last synced time.
- Update the date right after corresponding operations, and before reloading any "table view".
This commit is contained in:
parent
66688b5f66
commit
0197444e30
6 changed files with 15 additions and 13 deletions
|
|
@ -63,7 +63,7 @@ class AboutRepositoryTableViewController: BasicStaticTableViewController {
|
||||||
[[.style: CellDataStyle.value1, .accessoryType: type, .title: "Passwords", .detailText: numberOfPasswordsString],
|
[[.style: CellDataStyle.value1, .accessoryType: type, .title: "Passwords", .detailText: numberOfPasswordsString],
|
||||||
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Size", .detailText: sizeOfRepositoryString],
|
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Size", .detailText: sizeOfRepositoryString],
|
||||||
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Local Commits", .detailText: String(self?.passwordStore.numberOfLocalCommits() ?? 0)],
|
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Local Commits", .detailText: String(self?.passwordStore.numberOfLocalCommits() ?? 0)],
|
||||||
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Last Synced", .detailText: Utils.getLastUpdatedTimeString()],
|
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Last Synced", .detailText: Utils.getLastSyncedTimeString()],
|
||||||
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Commits", .detailText: numberOfCommitsString],
|
[.style: CellDataStyle.value1, .accessoryType: type, .title: "Commits", .detailText: numberOfCommitsString],
|
||||||
[.title: "Commit Logs", .action: "segue", .link: "showCommitLogsSegue"],
|
[.title: "Commit Logs", .action: "segue", .link: "showCommitLogsSegue"],
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
}
|
}
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.reloadTableView(parent: nil)
|
self.reloadTableView(parent: nil)
|
||||||
Defaults[.lastUpdatedTime] = Date()
|
|
||||||
Defaults[.gitRepositoryPasswordAttempts] = 0
|
Defaults[.gitRepositoryPasswordAttempts] = 0
|
||||||
SVProgressHUD.showSuccess(withStatus: "Done")
|
SVProgressHUD.showSuccess(withStatus: "Done")
|
||||||
SVProgressHUD.dismiss(withDelay: 1)
|
SVProgressHUD.dismiss(withDelay: 1)
|
||||||
|
|
@ -428,7 +427,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
self.tableView.layer.removeAnimation(forKey: "UITableViewReloadDataAnimationKey")
|
self.tableView.layer.removeAnimation(forKey: "UITableViewReloadDataAnimationKey")
|
||||||
|
|
||||||
// set the sync control title
|
// set the sync control title
|
||||||
let atribbutedTitle = "Last Synced: \(Utils.getLastUpdatedTimeString())"
|
let atribbutedTitle = "Last Synced: \(Utils.getLastSyncedTimeString())"
|
||||||
syncControl.attributedTitle = NSAttributedString(string: atribbutedTitle)
|
syncControl.attributedTitle = NSAttributedString(string: atribbutedTitle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,6 @@ class SettingsTableViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
Defaults[.lastUpdatedTime] = Date()
|
|
||||||
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
|
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
|
||||||
Defaults[.gitRepositoryUsername] = username
|
Defaults[.gitRepositoryUsername] = username
|
||||||
Defaults[.gitRepositoryAuthenticationMethod] = auth
|
Defaults[.gitRepositoryAuthenticationMethod] = auth
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ extension DefaultsKeys {
|
||||||
static let gitRepositorySSHPublicKeyURL = DefaultsKey<URL?>("gitRepositorySSHPublicKeyURL")
|
static let gitRepositorySSHPublicKeyURL = DefaultsKey<URL?>("gitRepositorySSHPublicKeyURL")
|
||||||
static let gitRepositorySSHPrivateKeyURL = DefaultsKey<URL?>("gitRepositorySSHPrivateKeyURL")
|
static let gitRepositorySSHPrivateKeyURL = DefaultsKey<URL?>("gitRepositorySSHPrivateKeyURL")
|
||||||
|
|
||||||
static let lastUpdatedTime = DefaultsKey<Date?>("lasteUpdatedTime")
|
static let lastSyncedTime = DefaultsKey<Date?>("lastSyncedTime")
|
||||||
|
|
||||||
static let isTouchIDOn = DefaultsKey<Bool>("isTouchIDOn")
|
static let isTouchIDOn = DefaultsKey<Bool>("isTouchIDOn")
|
||||||
static let passcodeKey = DefaultsKey<String?>("passcodeKey")
|
static let passcodeKey = DefaultsKey<String?>("passcodeKey")
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,14 @@ class Utils {
|
||||||
removeFileIfExists(atPath: url.path)
|
removeFileIfExists(atPath: url.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func getLastUpdatedTimeString() -> String {
|
static func getLastSyncedTimeString() -> String {
|
||||||
var lastUpdatedTimeString = ""
|
guard let lastSyncedTime = Defaults[.lastSyncedTime] else {
|
||||||
if let lastUpdatedTime = Defaults[.lastUpdatedTime] {
|
return "Oops! Sync again?"
|
||||||
let formatter = DateFormatter()
|
|
||||||
formatter.dateStyle = .medium
|
|
||||||
formatter.timeStyle = .short
|
|
||||||
lastUpdatedTimeString = formatter.string(from: lastUpdatedTime)
|
|
||||||
}
|
}
|
||||||
return lastUpdatedTimeString
|
let formatter = DateFormatter()
|
||||||
|
formatter.dateStyle = .medium
|
||||||
|
formatter.timeStyle = .short
|
||||||
|
return formatter.string(from: lastSyncedTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func generatePassword(length: Int) -> String{
|
static func generatePassword(length: Int) -> String{
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,7 @@ class PasswordStore {
|
||||||
storeRepository = try GTRepository(url: storeURL)
|
storeRepository = try GTRepository(url: storeURL)
|
||||||
gitCredential = credential
|
gitCredential = credential
|
||||||
self.updatePasswordEntityCoreData()
|
self.updatePasswordEntityCoreData()
|
||||||
|
Defaults[.lastSyncedTime] = Date()
|
||||||
|
|
||||||
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
|
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
|
||||||
}
|
}
|
||||||
|
|
@ -319,6 +320,8 @@ class PasswordStore {
|
||||||
try storeRepository?.pull((storeRepository?.currentBranch())!, from: remote, withOptions: options, progress: transferProgressBlock)
|
try storeRepository?.pull((storeRepository?.currentBranch())!, from: remote, withOptions: options, progress: transferProgressBlock)
|
||||||
self.setAllSynced()
|
self.setAllSynced()
|
||||||
self.updatePasswordEntityCoreData()
|
self.updatePasswordEntityCoreData()
|
||||||
|
Defaults[.lastSyncedTime] = Date()
|
||||||
|
|
||||||
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
|
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -678,6 +681,8 @@ class PasswordStore {
|
||||||
try self.storeRepository?.reset(to: newHead, resetType: GTRepositoryResetType.hard)
|
try self.storeRepository?.reset(to: newHead, resetType: GTRepositoryResetType.hard)
|
||||||
self.setAllSynced()
|
self.setAllSynced()
|
||||||
self.updatePasswordEntityCoreData()
|
self.updatePasswordEntityCoreData()
|
||||||
|
Defaults[.lastSyncedTime] = nil
|
||||||
|
|
||||||
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
|
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
|
||||||
NotificationCenter.default.post(name: .passwordStoreChangeDiscarded, object: nil)
|
NotificationCenter.default.post(name: .passwordStoreChangeDiscarded, object: nil)
|
||||||
return localCommits.count
|
return localCommits.count
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue