Fix a small bug about password list refreshing
- Previously, reloadData() may not be in the main thread.
This commit is contained in:
parent
c93a63d8cc
commit
66688b5f66
1 changed files with 8 additions and 6 deletions
|
|
@ -86,7 +86,6 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(parent: parent)
|
passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(parent: parent)
|
||||||
} else {
|
} else {
|
||||||
passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(withDir: false)
|
passwordEntities = self.passwordStore.fetchPasswordEntityCoreData(withDir: false)
|
||||||
|
|
||||||
}
|
}
|
||||||
passwordsTableEntries = passwordEntities.map {
|
passwordsTableEntries = passwordEntities.map {
|
||||||
PasswordsTableEntry(title: $0.name!, isDir: $0.isDir, passwordEntity: $0)
|
PasswordsTableEntry(title: $0.name!, isDir: $0.isDir, passwordEntity: $0)
|
||||||
|
|
@ -109,8 +108,8 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
SVProgressHUD.showProgress(progress, status: "Encrypting")
|
SVProgressHUD.showProgress(progress, status: "Encrypting")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
// will trigger reloadTableView() by a notification
|
||||||
SVProgressHUD.showSuccess(withStatus: "Done")
|
SVProgressHUD.showSuccess(withStatus: "Done")
|
||||||
SVProgressHUD.dismiss(withDelay: 1)
|
SVProgressHUD.dismiss(withDelay: 1)
|
||||||
}
|
}
|
||||||
|
|
@ -174,9 +173,9 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
reloadTableView(parent: nil)
|
reloadTableView(parent: nil)
|
||||||
|
|
||||||
// reset the data table if some password (maybe another one) has been updated
|
// reset the data table if some password (maybe another one) has been updated
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(reloadTableView as (Void) -> Void), name: .passwordStoreUpdated, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(actOnReloadTableViewRelatedNotification), name: .passwordStoreUpdated, object: nil)
|
||||||
// reset the data table if the disaply settings have been changed
|
// reset the data table if the disaply settings have been changed
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(reloadTableView as (Void) -> Void), name: .passwordDisplaySettingChanged, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(actOnReloadTableViewRelatedNotification), name: .passwordDisplaySettingChanged, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(actOnSearchNotification), name: .passwordSearch, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(actOnSearchNotification), name: .passwordSearch, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -438,9 +437,12 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
|
||||||
reloadTableView(data: passwordsTableEntries, anim: anim)
|
reloadTableView(data: passwordsTableEntries, anim: anim)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadTableView() {
|
func actOnReloadTableViewRelatedNotification() {
|
||||||
initPasswordsTableEntries(parent: nil)
|
initPasswordsTableEntries(parent: nil)
|
||||||
reloadTableView(data: passwordsTableEntries)
|
DispatchQueue.main.async { [weak weakSelf = self] in
|
||||||
|
guard let strongSelf = weakSelf else { return }
|
||||||
|
strongSelf.reloadTableView(data: strongSelf.passwordsTableEntries)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleRefresh(_ syncControl: UIRefreshControl) {
|
func handleRefresh(_ syncControl: UIRefreshControl) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue