59 lines
1.3 KiB
Swift
59 lines
1.3 KiB
Swift
//
|
|
// Swiftfin is subject to the terms of the Mozilla Public
|
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
|
//
|
|
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
|
|
//
|
|
|
|
import Defaults
|
|
import Factory
|
|
import Foundation
|
|
import JellyfinAPI
|
|
|
|
// TODO: also have matching properties on `ServerState` that get/set values
|
|
|
|
// MARK: keys
|
|
|
|
extension StoredValues.Keys {
|
|
|
|
static func ServerKey<Value: Codable>(
|
|
_ name: String?,
|
|
ownerID: String,
|
|
domain: String,
|
|
default defaultValue: Value
|
|
) -> Key<Value> {
|
|
guard let name else {
|
|
return Key(always: defaultValue)
|
|
}
|
|
|
|
return Key(
|
|
name,
|
|
ownerID: ownerID,
|
|
domain: domain,
|
|
default: defaultValue
|
|
)
|
|
}
|
|
|
|
static func ServerKey<Value: Codable>(always: Value) -> Key<Value> {
|
|
Key(always: always)
|
|
}
|
|
}
|
|
|
|
// MARK: values
|
|
|
|
extension StoredValues.Keys {
|
|
|
|
enum Server {
|
|
|
|
static func publicInfo(id: String) -> Key<PublicSystemInfo> {
|
|
ServerKey(
|
|
"publicInfo",
|
|
ownerID: id,
|
|
domain: "publicInfo",
|
|
default: .init()
|
|
)
|
|
}
|
|
}
|
|
}
|