Merge pull request #2475 from keymanapp/feat/ios/2357-no-dictionary-notification

feat(ios): clean message + auto-return when no dictionaries available
This commit is contained in:
Joshua Horton 2020-01-15 12:38:01 +07:00 committed by GitHub
commit 08178c2de5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -308,9 +308,9 @@ class LexicalModelPickerViewController: UITableViewController, UIAlertViewDelega
self.lexicalModelDownloadFailed(LexicalModelDownloadFailedNotification(lmOrLanguageID: self.language.id, error: error))
}
} else if nil == lexicalModels {
log.info("No lexical models available for language \(language.id) (nil)")
noModelsAvailable(cause: "nil")
} else if 0 == lexicalModels?.count {
log.info("No lexical models available for language \(language.id) (empty)")
noModelsAvailable(cause: "empty")
} else {
log.info("Fetched lexical model list for "+language.id+".")
// show the list of lexical models (on the main thread)
@ -326,6 +326,22 @@ class LexicalModelPickerViewController: UITableViewController, UIAlertViewDelega
Manager.shared.apiLexicalModelRepository.fetchList(languageID: language.id, completionHandler: listCompletionHandler)
}
func noModelsAvailable(cause: String = "nil") {
let msg = "No dictionaries available"
let logMsg = "No lexical models available for language \(language.id) (\(cause))"
log.info(logMsg)
let alertController = UIAlertController(title: title, message: msg,
preferredStyle: UIAlertController.Style.alert)
alertController.addAction(UIAlertAction(title: "OK",
style: UIAlertAction.Style.default,
handler: { _ in
self.navigationController?.popViewController(animated: true)
}))
self.present(alertController, animated: true, completion: nil)
}
}