- Add BookmarkState enum with unread, favorite, and archived states - Extend API layer with query parameter filtering for bookmark states - Update Bookmark domain model to match complete API response schema - Implement BookmarkListView with card-based UI and preview images - Add BookmarkListViewModel with state management and error handling - Enhance BookmarkDetailView with meta information and WebView rendering - Create comprehensive DTO mapping for all bookmark fields - Add TabView with state-based bookmark filtering - Implement date formatting utilities for ISO8601 timestamps - Add progress indicators and pull-to-refresh functionality
45 lines
1.0 KiB
Swift
45 lines
1.0 KiB
Swift
import Foundation
|
|
|
|
@Observable
|
|
class TokenManager {
|
|
static let shared = TokenManager()
|
|
|
|
private let settingsRepository = SettingsRepository()
|
|
private var cachedSettings: Settings?
|
|
|
|
private init() {}
|
|
|
|
var currentToken: String? {
|
|
cachedSettings?.token
|
|
}
|
|
|
|
var currentEndpoint: String? {
|
|
cachedSettings?.endpoint
|
|
}
|
|
|
|
func loadSettings() async {
|
|
do {
|
|
cachedSettings = try await settingsRepository.loadSettings()
|
|
} catch {
|
|
print("Failed to load settings: \(error)")
|
|
}
|
|
}
|
|
|
|
func updateToken(_ token: String) async {
|
|
do {
|
|
try await settingsRepository.saveToken(token)
|
|
cachedSettings?.token = token
|
|
} catch {
|
|
print("Failed to save token: \(error)")
|
|
}
|
|
}
|
|
|
|
func clearToken() async {
|
|
do {
|
|
try await settingsRepository.clearSettings()
|
|
cachedSettings = nil
|
|
} catch {
|
|
print("Failed to clear settings: \(error)")
|
|
}
|
|
}
|
|
} |