From: Claudio Cambra Date: Tue, 27 Feb 2024 12:28:55 +0000 (+0800) Subject: Add item shares loading routine to ShareTableViewDataSource X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~7^2~46^2~143 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d3260989fd4632d6e8abcaa11ea96dedbaca087f;p=nextcloud-desktop.git Add item shares loading routine to ShareTableViewDataSource Signed-off-by: Claudio Cambra --- diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift index 8ec218668..63ff845a6 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -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") } diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift index 77fc2e42f..7d19fb7fe 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareTableViewDataSource.swift @@ -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 {