зеркало из https://github.com/nextcloud/talk-ios.git
Show error message and disable copy button when there are no test results
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
ec0ca7753a
Коммит
cb991310b8
|
@ -651,16 +651,21 @@ class DiagnosticsTableViewController: UITableViewController {
|
|||
|
||||
func testPushNotifications() {
|
||||
self.showPushNotificationTestRunningIndicator()
|
||||
NCAPIController.sharedInstance().testPushnotifications(forAccount: account) { result, _ in
|
||||
let alert = UIAlertController(title: NSLocalizedString("Test results", comment: ""),
|
||||
message: result,
|
||||
NCAPIController.sharedInstance().testPushnotifications(forAccount: account) { result in
|
||||
let isEmptyResult = result?.isEmpty ?? true
|
||||
let title = isEmptyResult ? NSLocalizedString("Test failed", comment: "") : NSLocalizedString("Test results", comment: "")
|
||||
let message = isEmptyResult ? NSLocalizedString("An error occurred while testing push notifications", comment: "") : result
|
||||
let alert = UIAlertController(title: title,
|
||||
message: message,
|
||||
preferredStyle: .alert)
|
||||
|
||||
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default))
|
||||
alert.addAction(UIAlertAction(title: NSLocalizedString("Copy", comment: ""), style: .default) { _ in
|
||||
UIPasteboard.general.string = result
|
||||
NotificationPresenter.shared().present(text: NSLocalizedString("Test results copied", comment: ""), dismissAfterDelay: 5.0, includedStyle: .dark)
|
||||
})
|
||||
if !isEmptyResult {
|
||||
alert.addAction(UIAlertAction(title: NSLocalizedString("Copy", comment: ""), style: .default) { _ in
|
||||
UIPasteboard.general.string = result
|
||||
NotificationPresenter.shared().present(text: NSLocalizedString("Test results copied", comment: ""), dismissAfterDelay: 5.0, includedStyle: .dark)
|
||||
})
|
||||
}
|
||||
NCUserInterfaceController.sharedInstance().presentAlertViewController(alert)
|
||||
self.hidePushNotificationTestRunningIndicator()
|
||||
}
|
||||
|
|
|
@ -562,10 +562,10 @@ import Foundation
|
|||
|
||||
// MARK: - Push notification test
|
||||
|
||||
public func testPushnotifications(forAccount account: TalkAccount, completionBlock: @escaping (_ result: String?, _ error: Error?) -> Void) {
|
||||
public func testPushnotifications(forAccount account: TalkAccount, completionBlock: @escaping (_ result: String?) -> Void) {
|
||||
guard let apiSessionManager = self.apiSessionManagers.object(forKey: account.accountId) as? NCAPISessionManager
|
||||
else {
|
||||
completionBlock(nil, nil)
|
||||
completionBlock(nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ import Foundation
|
|||
|
||||
apiSessionManager.postOcs(urlString, account: account) { ocsResponse, ocsError in
|
||||
let message = ocsResponse?.dataDict?["message"] as? String
|
||||
completionBlock(message, ocsError?.error)
|
||||
completionBlock(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,6 +283,9 @@
|
|||
/* No comment provided by engineer. */
|
||||
"An error occurred while sharing the file" = "An error occurred while sharing the file";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"An error occurred while testing push notifications" = "An error occurred while testing push notifications";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"an hour" = "an hour";
|
||||
|
||||
|
@ -1726,6 +1729,9 @@
|
|||
/* No comment provided by engineer. */
|
||||
"Tap and hold to record a voice message, release the button to send it." = "Tap and hold to record a voice message, release the button to send it.";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Test failed" = "Test failed";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Test push notifications" = "Test push notifications";
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче