mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
- Add personal pins (My sessions), global/project pin separation, H5 running/pending and active/idle buckets, and collapsible project groups with counts and selected-row expansion. - Add local personal pin storage and list-specific display metrics. - Add Settings > Appearance list text size (80-130%) and CLI/code font size (9-17 pt), with Dynamic Type still applied. - Keep search flat and filters force groups open; shared/archived/status detail/preview-fold remain out of scope. - Bump the local build to 14. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
43 lines
1.2 KiB
Swift
43 lines
1.2 KiB
Swift
import Foundation
|
|
import Observation
|
|
|
|
/// Install-global, client-only personal pins ("My sessions" in the web
|
|
/// sidebar). This never talks to the hub; it is the iOS counterpart of the
|
|
/// web `localStorage` set.
|
|
@MainActor @Observable
|
|
public final class PersonalPinStore {
|
|
public static let key = "settings.personalPinnedSessions"
|
|
public static let shared = PersonalPinStore()
|
|
|
|
public private(set) var sessionIds: Set<String>
|
|
|
|
private let defaults: UserDefaults
|
|
|
|
public init(defaults: UserDefaults = .standard) {
|
|
self.defaults = defaults
|
|
self.sessionIds = Set(defaults.stringArray(forKey: Self.key) ?? [])
|
|
}
|
|
|
|
public func contains(_ sessionId: String) -> Bool {
|
|
sessionIds.contains(sessionId)
|
|
}
|
|
|
|
public func toggle(_ sessionId: String) {
|
|
if sessionIds.contains(sessionId) {
|
|
sessionIds.remove(sessionId)
|
|
} else {
|
|
sessionIds.insert(sessionId)
|
|
}
|
|
persist()
|
|
}
|
|
|
|
public func remove(_ sessionId: String) {
|
|
guard sessionIds.remove(sessionId) != nil else { return }
|
|
persist()
|
|
}
|
|
|
|
private func persist() {
|
|
defaults.set(sessionIds.sorted(), forKey: Self.key)
|
|
}
|
|
}
|