Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iOSClient/Account/NCAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class NCAccount: NSObject {
return
}

await showErrorBanner(controller: controller, text: "_account_unauthorized_")
await showErrorBanner(controller: controller, text: "_account_unauthorized_", errorCode: NCGlobal.shared.errorUnauthorized401)

let resultsWipe = await NextcloudKit.shared.getRemoteWipeStatusAsync(serverUrl: tblAccount.urlBase, token: token, account: account) { task in
Task {
Expand Down
8 changes: 4 additions & 4 deletions iOSClient/Activity/NCActivity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class NCActivity: UIViewController, NCSharePagingContent {
self.loadComments()
} else {
Task {
await showErrorBanner(controller: self.tabBarController, text: error.errorDescription)
await showErrorBanner(controller: self.tabBarController, text: error.errorDescription, errorCode: error.errorCode)
}
}
}
Expand Down Expand Up @@ -439,7 +439,7 @@ extension NCActivity {
self.database.addComments(comments, account: metadata.account, objectId: metadata.fileId)
} else if error.errorCode != NCGlobal.shared.errorResourceNotFound {
Task {
await showErrorBanner(controller: self.tabBarController, text: error.errorDescription)
await showErrorBanner(controller: self.tabBarController, text: error.errorDescription, errorCode: error.errorCode)
}
}

Expand Down Expand Up @@ -579,7 +579,7 @@ extension NCActivity: NCShareCommentsCellDelegate {
self.loadComments()
} else {
Task {@MainActor in
await showErrorBanner(controller: self.tabBarController, text: error.errorDescription)
await showErrorBanner(controller: self.tabBarController, text: error.errorDescription, errorCode: error.errorCode)
}
}
}
Expand Down Expand Up @@ -611,7 +611,7 @@ extension NCActivity: NCShareCommentsCellDelegate {
self.loadComments()
} else {
Task {
await showErrorBanner(controller: self.tabBarController, text: error.errorDescription)
await showErrorBanner(controller: self.tabBarController, text: error.errorDescription, errorCode: error.errorCode)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Activity/NCActivityTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extension NCActivityTableViewCell: UICollectionViewDelegate {
(responder as? UIViewController)!.navigationController?.pushViewController(viewController, animated: true)
} else {
Task {
await showErrorBanner(controller: viewController.controller, text: "_trash_file_not_found_")
await showErrorBanner(controller: viewController.controller, text: "_trash_file_not_found_", errorCode: 0)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
return
}

try? await Task.sleep(nanoseconds: 1_000_000_000)
try? await Task.sleep(for: .seconds(1))

let tblAccounts = await NCManageDatabase.shared.getAllTableAccountAsync()
for tblAccount in tblAccounts {
Expand Down Expand Up @@ -406,7 +406,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
if app == NCGlobal.shared.termsOfServiceName {
Task {
await NCNetworking.shared.transferDispatcher.notifyAllDelegatesAsync { delegate in
try? await Task.sleep(nanoseconds: 500_000_000)
try? await Task.sleep(for: .seconds(0.5))
delegate.transferReloadDataSource(serverUrl: nil, requestData: true, status: nil)
}
}
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/Extensions/UIAlertController+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ extension UIAlertController {
if createFolderResults.error == .success {
let error = await NCNetworkingE2EEMarkFolder().markFolderE2ee(account: session.account, serverUrlFileName: serverUrlFileName, userId: session.userId)
if error != .success {
await showErrorBanner(scene: scene, text: error.errorDescription)
await showErrorBanner(scene: scene, text: error.errorDescription, errorCode: error.errorCode)
}
} else {
await showErrorBanner(scene: scene, text: createFolderResults.error.errorDescription)
await showErrorBanner(scene: scene, text: createFolderResults.error.errorDescription, errorCode: createFolderResults.error.errorCode)
}
}
} else if isDirectoryEncrypted {
Expand Down
8 changes: 4 additions & 4 deletions iOSClient/Files/NCFiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ class NCFiles: NCCollectionViewCommon {
await showInfoBanner(controller: self.controller, text: "Metadata not found")
let error = await NCNetworkingE2EE().uploadMetadata(serverUrl: serverUrl, account: account)
if error != .success {
await showErrorBanner(controller: self.controller, text: error.errorDescription)
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}
} else {
// show error
await showErrorBanner(controller: self.controller, text: error.errorDescription)
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}

return(metadatas, error, reloadRequired)
Expand All @@ -343,14 +343,14 @@ class NCFiles: NCCollectionViewCommon {

let error = await NCNetworkingE2EE().uploadMetadata(serverUrl: serverUrl, updateVersionV1V2: true, account: account)
if error != .success {
await showErrorBanner(controller: self.controller, text: error.errorDescription)
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}
NCActivityIndicator.shared.stop()
}
} else {
// Client Diagnostic
await self.database.addDiagnosticAsync(account: account, issue: NCGlobal.shared.diagnosticIssueE2eeErrors)
await showErrorBanner(controller: self.controller, text: error.errorDescription)
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}

return (metadatas, error, reloadRequired)
Expand Down
38 changes: 30 additions & 8 deletions iOSClient/GUI/Lucid Banner/BannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,17 @@ func showErrorBannerActiveScenes(title: String = "_error_",
footnote: String? = nil,
foregroundColor: UIColor = .white,
backgroundColor: UIColor = .red,
sleepBefore: Double = 1) async {
sleepBefore: Double = 1,
errorCode: Int) async {
for scene in UIApplication.shared.foregroundActiveScenes {
await showErrorBanner(scene: scene,
title: title,
text: text,
footnote: footnote,
foregroundColor: foregroundColor,
backgroundColor: backgroundColor,
sleepBefore: sleepBefore)
sleepBefore: sleepBefore,
errorCode: errorCode)
}
}

Expand All @@ -178,14 +180,16 @@ func showErrorBanner(controller: UITabBarController?,
footnote: String? = nil,
foregroundColor: UIColor = .white,
backgroundColor: UIColor = .red,
sleepBefore: Double = 1) async {
sleepBefore: Double = 1,
errorCode: Int) async {
let scene = SceneManager.shared.getWindow(controller: controller)?.windowScene
await showErrorBanner(scene: scene,
text: text,
footnote: footnote,
foregroundColor: foregroundColor,
backgroundColor: backgroundColor,
sleepBefore: sleepBefore)
sleepBefore: sleepBefore,
errorCode: errorCode)
}

@MainActor
Expand All @@ -195,14 +199,16 @@ func showErrorBanner(sceneIdentifier: String?,
footnote: String? = nil,
foregroundColor: UIColor = .white,
backgroundColor: UIColor = .red,
sleepBefore: Double = 1) async {
sleepBefore: Double = 1,
errorCode: Int) async {
await showErrorBanner(controller: SceneManager.shared.getController(sceneIdentifier: sceneIdentifier),
title: title,
text: text,
footnote: footnote,
foregroundColor: foregroundColor,
backgroundColor: backgroundColor,
sleepBefore: sleepBefore)
sleepBefore: sleepBefore,
errorCode: errorCode)
}

#endif
Expand All @@ -214,12 +220,28 @@ func showErrorBanner(scene: UIWindowScene?,
footnote: String? = nil,
foregroundColor: UIColor = .white,
backgroundColor: UIColor = .red,
sleepBefore: Double = 1) async {
try? await Task.sleep(nanoseconds: UInt64(sleepBefore * 1e9))
sleepBefore: Double = 1,
errorCode: Int) async {
#if !EXTENSION
// Prevent repeated display of the same user-facing error during the current foreground session.
// If this error code has already been shown, do nothing.
// Otherwise, record it and allow the UX notification to be displayed once.
if shownErrors.contains(errorCode) {
return
} else {
// Coalesce user-facing errors across the current foreground session.
// The same error code is shown to the user only once.
// Error 507 (insufficient storage) is recorded to avoid repeated UX notifications
// for subsequent uploads failing for the same reason.
if errorCode == 507 {
shownErrors.insert(errorCode)
}
}
let scene = scene ?? UIApplication.shared.mainAppWindow?.windowScene
#endif

try? await Task.sleep(for: .seconds(sleepBefore))

let payload = LucidBannerPayload(
title: NSLocalizedString(title, comment: ""),
subtitle: NSLocalizedString(text, comment: ""),
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/GUI/Lucid Banner/HudBannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ private struct HudBannerPreviewWrapper: View {
HudBannerView(state: state)
.task {
for i in 0...100 {
try? await Task.sleep(nanoseconds: 45_000_000)
try? await Task.sleep(for: .milliseconds(45))
state.payload.progress = Double(i) / 100
}

try? await Task.sleep(nanoseconds: 400_000_000)
try? await Task.sleep(for: .seconds(0.4))
state.payload.stage = .success
}
}
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Login/NCLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
self.createAccount(urlBase: urlBase, user: user, password: password)
} else {
Task {
await showErrorBanner(controller: self.controller, text: error.errorDescription)
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}
self.dismiss(animated: true, completion: nil)
}
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/Login/NCLoginProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class NCLoginProvider: UIViewController {

guard let url = URL(string: initialURLString) else {
Task {
await showErrorBanner(controller: self.controller, text: "_login_url_error_")
await showErrorBanner(controller: self.controller, text: "_login_url_error_", errorCode: 0)
}
return
}
Expand Down Expand Up @@ -196,7 +196,7 @@ class NCLoginProvider: UIViewController {
try Task.checkCancellation()

grantValues = await poll(token: token, endpoint: endpoint, options: options)
try await Task.sleep(nanoseconds: 1_000_000_000) // .seconds() is not supported on iOS 15 yet.
try await Task.sleep(for: .seconds(1))
} while grantValues == nil

guard let grantValues else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
if results.nkError == .success || results.afError?.isExplicitlyCancelledError ?? false {
print("ok")
} else {
await showErrorBanner(scene: scene, text: results.nkError.errorDescription)
await showErrorBanner(scene: scene, text: results.nkError.errorDescription, errorCode: results.nkError.errorCode)
}
}

Expand Down Expand Up @@ -118,7 +118,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
}
} else {
Task {
await showErrorBanner(controller: controller, text: "_go_online_")
await showErrorBanner(controller: controller, text: "_go_online_", errorCode: NCGlobal.shared.errorOffline)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
self.refreshControl.endRefreshing()

// Wait 1.5 seconds before resetting the button alpha
try? await Task.sleep(nanoseconds: 1_500_000_000)
try? await Task.sleep(for: .seconds(1.5))
self.mainNavigationController?.resetPlusButtonAlpha()
}
}
Expand Down Expand Up @@ -627,7 +627,7 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
}
} else {
Task {
await showErrorBanner(scene: scene, text: resultsUpload.error.errorDescription)
await showErrorBanner(scene: scene, text: resultsUpload.error.errorDescription, errorCode: resultsUpload.error.errorCode)
}
}
}
Expand Down Expand Up @@ -748,7 +748,7 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate,
} completion: { _, searchResult, metadatas, error in
if error != .success {
Task {
await showErrorBanner(controller: self.controller, text: error.errorDescription)
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}
}

Expand Down Expand Up @@ -919,7 +919,7 @@ extension NCCollectionViewCommon: NCTransferDelegate {
Task {
if error != .success,
error.errorCode != global.errorResourceNotFound {
await showErrorBanner(controller: self.controller, text: error.errorDescription)
await showErrorBanner(controller: self.controller, text: error.errorDescription, errorCode: error.errorCode)
}
guard session.account == account else {
return
Expand Down
4 changes: 2 additions & 2 deletions iOSClient/Main/Create/NCCreate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NCCreate: NSObject {
}
guard results.error == .success, let url = results.url else {
Task {
await showErrorBanner(controller: controller, text: results.error.errorDescription)
await showErrorBanner(controller: controller, text: results.error.errorDescription, errorCode: results.error.errorCode)
}
return
}
Expand All @@ -68,7 +68,7 @@ class NCCreate: NSObject {
}
guard results.error == .success, let url = results.url else {
Task {
await showErrorBanner(controller: controller, text: results.error.errorDescription)
await showErrorBanner(controller: controller, text: results.error.errorDescription, errorCode: results.error.errorCode)
}
return
}
Expand Down
6 changes: 3 additions & 3 deletions iOSClient/Main/NCDragDrop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class NCDragDrop: NSObject {
database.addMetadata(metadataForUpload)
} catch {
Task {
await showErrorBanner(controller: controller, text: error.localizedDescription)
await showErrorBanner(controller: controller, text: error.localizedDescription, errorCode: 0)
}
return
}
Expand Down Expand Up @@ -235,7 +235,7 @@ class NCDragDrop: NSObject {
downloadRequest = request
}
guard results.nkError == .success else {
await showErrorBanner(scene: scene, text: results.nkError.errorDescription)
await showErrorBanner(scene: scene, text: results.nkError.errorDescription, errorCode: results.nkError.errorCode)
break
}
}
Expand All @@ -257,7 +257,7 @@ class NCDragDrop: NSObject {
uploadRequest = request
}
guard results.error == .success else {
await showErrorBanner(scene: scene, text: results.error.errorDescription)
await showErrorBanner(scene: scene, text: results.error.errorDescription, errorCode: results.error.errorCode)
break
}

Expand Down
4 changes: 1 addition & 3 deletions iOSClient/Main/NCMainTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,8 @@ class NCMainTabBarController: UITabBarController {

@MainActor
private func timerCheck() async {
let nanoseconds: UInt64 = 3_000_000_000

while !Task.isCancelled {
try? await Task.sleep(nanoseconds: nanoseconds)
try? await Task.sleep(for: .seconds(3))

guard isViewLoaded, view.window != nil else {
continue
Expand Down
6 changes: 3 additions & 3 deletions iOSClient/Main/NCPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ class NCPhotosPickerViewController: NSObject {

pickerVC?.didExceedMaximumNumberOfSelection = { _ in
Task {
await showErrorBanner(controller: self.controller, text: "_limited_dimension_")
await showErrorBanner(controller: self.controller, text: "_limited_dimension_", errorCode: 0)
}
}

pickerVC?.handleNoAlbumPermissions = { _ in
Task {
await showErrorBanner(controller: self.controller, text: "_denied_album_")
await showErrorBanner(controller: self.controller, text: "_denied_album_", errorCode: 0)
}
}

pickerVC?.handleNoCameraPermissions = { _ in
Task {
await showErrorBanner(controller: self.controller, text: "_denied_camera_")
await showErrorBanner(controller: self.controller, text: "_denied_camera_", errorCode: 0)
}
}

Expand Down
Loading
Loading