Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'iOSClient/Utility/NCContentPresenter.swift')
-rw-r--r--iOSClient/Utility/NCContentPresenter.swift45
1 files changed, 31 insertions, 14 deletions
diff --git a/iOSClient/Utility/NCContentPresenter.swift b/iOSClient/Utility/NCContentPresenter.swift
index 79061d600..8365da0c4 100644
--- a/iOSClient/Utility/NCContentPresenter.swift
+++ b/iOSClient/Utility/NCContentPresenter.swift
@@ -24,6 +24,7 @@
import SwiftEntryKit
import UIKit
import CFNetwork
+import NextcloudKit
class NCContentPresenter: NSObject {
@objc static let shared: NCContentPresenter = {
@@ -62,35 +63,51 @@ class NCContentPresenter: NSObject {
// MARK: - Message
- @objc func showError(description: String, errorCode: Int = NCGlobal.shared.errorGeneric) {
+ func showError(error: NKError, priority: EKAttributes.Precedence.Priority = .normal) {
messageNotification(
- "_error_", description: description,
+ "_error_",
+ error: error,
delay: NCGlobal.shared.dismissAfterSecond,
type: .error,
- errorCode: errorCode)
+ priority: priority)
}
- @objc func messageNotification(_ title: String, description: String?, delay: TimeInterval, type: messageType, errorCode: Int) {
- messageNotification(title, description: description, delay: delay, type: type, errorCode: errorCode, priority: .normal, dropEnqueuedEntries: false)
+ func showInfo(error: NKError, priority: EKAttributes.Precedence.Priority = .normal) {
+ messageNotification(
+ "_info_",
+ error: error,
+ delay: NCGlobal.shared.dismissAfterSecond,
+ type: .info,
+ priority: priority)
+ }
+
+ func showWarning(error: NKError, priority: EKAttributes.Precedence.Priority = .normal) {
+ messageNotification(
+ "_warning_",
+ error: error,
+ delay: NCGlobal.shared.dismissAfterSecond,
+ type: .info,
+ priority: priority)
+ }
+
+ @objc func messageNotification(_ title: String, error: NKError, delay: TimeInterval, type: messageType) {
+ messageNotification(title, error: error, delay: delay, type: type, priority: .normal, dropEnqueuedEntries: false)
}
- func messageNotification(_ title: String, description: String?, delay: TimeInterval, type: messageType, errorCode: Int, priority: EKAttributes.Precedence.Priority = .normal, dropEnqueuedEntries: Bool = false) {
+ func messageNotification(_ title: String, error: NKError, delay: TimeInterval, type: messageType, priority: EKAttributes.Precedence.Priority = .normal, dropEnqueuedEntries: Bool = false) {
// No notification message for:
- if errorCode == -999 { return } // Cancelled transfer
- else if errorCode == 200 { return } // Transfer stopped
- else if errorCode == 207 { return } // WebDAV multistatus
- else if errorCode == NCGlobal.shared.errorNoError && type == messageType.error { return }
+ if error.errorCode == NSURLErrorCancelled || error.errorCode == NCGlobal.shared.errorRequestExplicityCancelled { return } // Cancelled transfer
+ else if error == .success && type == messageType.error { return }
DispatchQueue.main.async {
- switch errorCode {
+ switch error.errorCode {
case Int(CFNetworkErrors.cfurlErrorNotConnectedToInternet.rawValue):
let image = UIImage(named: "networkInProgress")!.image(color: .white, size: 20)
self.noteTop(text: NSLocalizedString(title, comment: ""), image: image, color: .lightGray, delay: delay, priority: .max)
default:
- guard var description = description else { return }
- if description.trimmingCharacters(in: .whitespacesAndNewlines) == "" { return }
- description = NSLocalizedString(description, comment: "")
+ if error.errorDescription.trimmingCharacters(in: .whitespacesAndNewlines) == "" { return }
+ let description = NSLocalizedString(error.errorDescription, comment: "")
self.flatTop(title: NSLocalizedString(title, comment: ""), description: description, delay: delay, imageName: nil, type: type, priority: priority, dropEnqueuedEntries: dropEnqueuedEntries)
}
}