mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-29 04:08:54 +03:00
Pull out error handling from completionHandler for nckit lockunlock
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
cce98f1e84
commit
4db6f8c2ed
1 changed files with 8 additions and 9 deletions
|
@ -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).")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue