22 lines
850 B
Swift
22 lines
850 B
Swift
import Foundation
|
|
import HelderCore
|
|
import HelderServices
|
|
@testable import HelderUI
|
|
|
|
/// Sessions and the agent split, in memory instead of UserDefaults.
|
|
final class FakeSession: SessionStoring, @unchecked Sendable {
|
|
private let state = Locked((sessions: [String: SessionState](), layout: LayoutState()))
|
|
|
|
var sessions: [String: SessionState] {
|
|
get { state.current.sessions }
|
|
set { state.mutate { $0.sessions = newValue } }
|
|
}
|
|
|
|
var layout: LayoutState { state.current.layout }
|
|
|
|
func loadSession(root: String) -> SessionState? { state.current.sessions[root] }
|
|
func saveSession(_ session: SessionState, root: String) { state.mutate { $0.sessions[root] = session } }
|
|
func loadLayout() -> LayoutState { state.current.layout }
|
|
func saveLayout(_ layout: LayoutState) { state.mutate { $0.layout = layout } }
|
|
}
|