From: Claudio Cambra Date: Wed, 31 Jul 2024 07:16:59 +0000 (+0800) Subject: Pull out error handling from completionHandler for nckit lockunlock X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~6^2~22^2~10 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4db6f8c2edc577660d3af2f8b018502e20ace245;p=nextcloud-desktop.git Pull out error handling from completionHandler for nckit lockunlock Signed-off-by: Claudio Cambra --- diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Locking/LockViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Locking/LockViewController.swift index d261c0955..d170fc26b 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Locking/LockViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Locking/LockViewController.swift @@ -174,21 +174,20 @@ class LockViewController: NSViewController { descriptionLabel.stringValue = "Communicating with server, \(locking ? "locking" : "unlocking") file…" - await withCheckedContinuation { continuation in + let error = await withCheckedContinuation { continuation in kit.lockUnlockFile( serverUrlFileName: itemServerRelativePath, shouldLock: locking, - completion: { account, error in - if error == .success { - self.descriptionLabel.stringValue = - "File \(self.locking ? "locked" : "unlocked")!" - continuation.resume() - } else { - self.presentError("Could not lock file: \(error).") - } + completion: { _, error in + continuation.resume(returning: error) } ) } + if error == .success { + descriptionLabel.stringValue = "File \(self.locking ? "locked" : "unlocked")!" + } else { + presentError("Could not lock file: \(error.errorDescription).") + } } catch let error { presentError("Could not lock file: \(error).") }