Polish and simplify PasswordStore model class

This commit is contained in:
Bob Sun 2017-04-30 16:16:52 -05:00
parent fb42da4013
commit eba79da0e6
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
5 changed files with 230 additions and 168 deletions

View file

@ -16,7 +16,7 @@ class CommitLogsTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(updateCommitLogs), name: .passwordStoreUpdated, object: nil)
commits = passwordStore.getRecentCommits(count: 20)
commits = getCommitLogs()
self.tableView.estimatedRowHeight = 50
self.tableView.rowHeight = UITableViewAutomaticDimension
}
@ -41,8 +41,17 @@ class CommitLogsTableViewController: UITableViewController {
return cell
}
func updateCommitLogs () {
commits = passwordStore.getRecentCommits(count: 20)
func updateCommitLogs() {
commits = getCommitLogs()
tableView.reloadData()
}
private func getCommitLogs() -> [GTCommit] {
do {
return try passwordStore.getRecentCommits(count: 20)
} catch {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
return []
}
}
}