mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 20:45:51 +03:00
Add item shares loading routine to ShareTableViewDataSource
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
6dad778498
commit
1288448336
2 changed files with 21 additions and 0 deletions
|
@ -11,6 +11,7 @@ extension Logger {
|
|||
private static var subsystem = Bundle.main.bundleIdentifier!
|
||||
|
||||
static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController")
|
||||
static let sharesDataSource = Logger(subsystem: subsystem, category: "sharesDataSource")
|
||||
static let shareViewController = Logger(subsystem: subsystem, category: "shareViewController")
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
import AppKit
|
||||
import FileProvider
|
||||
import NextcloudKit
|
||||
import OSLog
|
||||
|
||||
class ShareTableViewDataSource: NSObject, NSTableViewDataSource {
|
||||
var sharesTableView: NSTableView? {
|
||||
didSet {
|
||||
|
@ -21,6 +23,24 @@ class ShareTableViewDataSource: NSObject, NSTableViewDataSource {
|
|||
didSet { sharesTableView?.reloadData() }
|
||||
}
|
||||
|
||||
func loadItem(identifier: NSFileProviderItemIdentifier, url: URL) {
|
||||
itemIdentifier = identifier
|
||||
itemURL = url
|
||||
Task {
|
||||
await reload()
|
||||
}
|
||||
}
|
||||
|
||||
private func reload() async {
|
||||
guard let itemIdentifier = itemIdentifier, let itemURL = itemURL else { return }
|
||||
do {
|
||||
let connection = try await serviceConnection(url: itemURL)
|
||||
shares = await connection.shares(forItemIdentifier: itemIdentifier) ?? []
|
||||
} catch let error {
|
||||
Logger.sharesDataSource.error("Could not reload data: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
private func serviceConnection(url: URL) async throws -> FPUIExtensionService {
|
||||
let services = try await FileManager().fileProviderServicesForItem(at: url)
|
||||
guard let service = services[fpUiExtensionServiceName] else {
|
||||
|
|
Loading…
Reference in a new issue