From 3012976d9b9a91d88b560fff91c18523318d2e5f Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 2 Apr 2024 18:17:35 +0800 Subject: [PATCH] Add sharee fetcher method to shareesuggestionsdatasource Signed-off-by: Claudio Cambra --- .../Extensions/Logger+Extensions.swift | 1 + .../ShareeSuggestionsDataSource.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift index 54e3e599a..960171034 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -13,6 +13,7 @@ extension Logger { static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController") static let shareCapabilities = Logger(subsystem: subsystem, category: "shareCapabilities") static let shareController = Logger(subsystem: subsystem, category: "shareController") + static let shareeDataSource = Logger(subsystem: subsystem, category: "shareeDataSource") static let sharesDataSource = Logger(subsystem: subsystem, category: "sharesDataSource") static let shareOptionsView = Logger(subsystem: subsystem, category: "shareOptionsView") static let shareViewController = Logger(subsystem: subsystem, category: "shareViewController") diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift index f31db0ee1..17a7140b5 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareeSuggestionsDataSource.swift @@ -18,4 +18,23 @@ class ShareeSuggestionsDataSource: SuggestionsDataSource { init(kit: NextcloudKit) { self.kit = kit } + + private func fetchSharees(search: String) async -> [NKSharee] { + return await withCheckedContinuation { continuation in + kit.searchSharees( + search: inputString, + page: 1, + perPage: 20, + completion: { account, sharees, data, error in + defer { continuation.resume(returning: sharees ?? []) } + guard error == .success else { + Logger.shareeDataSource.error( + "Error fetching sharees: \(error.description, privacy: .public)" + ) + return + } + } + ) + } + } }