mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-29 20:28:57 +03:00
9a8af68ddc
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
40 lines
1.2 KiB
Swift
40 lines
1.2 KiB
Swift
//
|
|
// FileProviderConfig.swift
|
|
// FileProviderExt
|
|
//
|
|
// Created by Claudio Cambra on 5/2/24.
|
|
//
|
|
|
|
import FileProvider
|
|
import Foundation
|
|
|
|
struct FileProviderConfig {
|
|
private enum ConfigKey: String {
|
|
case fastEnumerationEnabled = "fastEnumerationEnabled"
|
|
}
|
|
|
|
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 fastEnumerationEnabled: Bool {
|
|
get { internalConfig[ConfigKey.fastEnumerationEnabled.rawValue] as? Bool ?? true }
|
|
set { internalConfig[ConfigKey.fastEnumerationEnabled.rawValue] = newValue }
|
|
}
|
|
|
|
lazy var fastEnumerationSet = internalConfig[ConfigKey.fastEnumerationEnabled.rawValue] != nil
|
|
}
|