Files
linkding-ios/Marks/MarksApp.swift
Krishna Kumar 525e6557c8
Some checks failed
CI / build-and-deploy (push) Failing after 6s
Replace manual backend config with auto JWT auth
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>
2026-05-22 14:14:54 -05:00

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)
}
}
}
}