nextcloud-desktop/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderConfig.swift
Claudio Cambra 9ff78ac969 feat(shell_integration/macOS/FileProviderExt): Remove fast enumeration settings
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
2025-06-02 15:15:32 +02:00

42 lines
1.3 KiB
Swift

//
// FileProviderConfig.swift
// FileProviderExt
//
// SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
// SPDX-License-Identifier: GPL-2.0-or-later
//
import FileProvider
import Foundation
struct FileProviderConfig {
private enum ConfigKey: String {
case trashDeletionEnabled = "trashDeletionEnabled"
}
let domainIdentifier: NSFileProviderDomainIdentifier
private var internalConfig: [String: Any] {
get {
let defaults = UserDefaults.standard
if let settings = defaults.dictionary(forKey: domainIdentifier.rawValue) {
return settings
}
let dictionary: [String: Any] = [:]
defaults.setValue(dictionary, forKey: domainIdentifier.rawValue)
return dictionary
}
set {
let defaults = UserDefaults.standard
defaults.setValue(newValue, forKey: domainIdentifier.rawValue)
}
}
var trashDeletionEnabled: Bool {
get { internalConfig[ConfigKey.trashDeletionEnabled.rawValue] as? Bool ?? true }
set { internalConfig[ConfigKey.trashDeletionEnabled.rawValue] = newValue }
}
lazy var trashDeletionSet = internalConfig[ConfigKey.trashDeletionEnabled.rawValue] != nil
}