Some checks failed
CI / build-and-deploy (push) Failing after 6s
Device auto-registers on first launch using hardcoded backend URL and anon key (MarksAuth.swift). 90-day JWT stored in UserDefaults, refreshed transparently. No settings fields needed — ClaudeService is always active and non-optional throughout the app. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
52 lines
1.4 KiB
Swift
52 lines
1.4 KiB
Swift
import SwiftUI
|
|
|
|
@main
|
|
struct MarksApp: App {
|
|
@State private var serverConfig: ServerConfig? = ServerConfig.load()
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
if let config = serverConfig {
|
|
MainContainer(config: config) {
|
|
config.delete()
|
|
serverConfig = nil
|
|
}
|
|
} else {
|
|
OnboardingView { newConfig in
|
|
newConfig.save()
|
|
serverConfig = newConfig
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Holds the API + ViewModel so they survive re-renders
|
|
struct MainContainer: View {
|
|
let config: ServerConfig
|
|
let onDisconnect: () -> Void
|
|
|
|
@State private var viewModel: BookmarksViewModel
|
|
|
|
init(config: ServerConfig, onDisconnect: @escaping () -> Void) {
|
|
self.config = config
|
|
self.onDisconnect = onDisconnect
|
|
let api = LinkdingAPI(config: config)
|
|
_viewModel = State(wrappedValue: BookmarksViewModel(api: api, cacheKey: config.host))
|
|
}
|
|
|
|
var body: some View {
|
|
TabView {
|
|
Tab("Bookmarks", systemImage: "bookmark") {
|
|
BookmarksView(viewModel: viewModel, onDisconnect: onDisconnect)
|
|
}
|
|
Tab("Tags", systemImage: "tag") {
|
|
TagsView(viewModel: viewModel)
|
|
}
|
|
Tab(role: .search) {
|
|
SearchView(viewModel: viewModel)
|
|
}
|
|
}
|
|
}
|
|
}
|