move database operations to the main thread to avoid async problems

This commit is contained in:
Bob Sun 2017-02-15 11:15:11 +08:00
parent 56cb5d94ee
commit 9f4830dc2a
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
3 changed files with 15 additions and 24 deletions

View file

@ -71,15 +71,16 @@ class PasswordRepositorySettingsTableViewController: BasicStaticTableViewControl
SVProgressHUD.showProgress(Float(completedSteps)/Float(totalSteps), status: "Checkout Master Branch")
}
})
DispatchQueue.main.async {
PasswordStore.shared.updatePasswordEntityCoreData()
Defaults[.lastUpdatedTime] = Date()
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
Defaults[.gitRepositoryUsername] = username
Defaults[.gitRepositoryPassword] = password
Defaults[.gitRepositoryAuthenticationMethod] = auth
SVProgressHUD.showSuccess(withStatus: "Done")
SVProgressHUD.dismiss(withDelay: 1)
Defaults[.lastUpdatedTime] = Date()
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
}
} catch {
DispatchQueue.main.async {
@ -91,11 +92,6 @@ class PasswordRepositorySettingsTableViewController: BasicStaticTableViewControl
}
}
Defaults[.gitRepositoryURL] = URL(string: gitRepostiroyURL)
Defaults[.gitRepositoryUsername] = username
Defaults[.gitRepositoryPassword] = password
Defaults[.gitRepositoryAuthenticationMethod] = auth
}
}
}