Files
linkding-ios/Marks/MarksApp.swift
Krishna Kumar 1b40f50aab Add edit bookmark, offline cache, and unread filter
- Edit bookmark: full PATCH via swipe action or long-press context menu;
  EditBookmarkView covers URL, title, description, tags, and unread toggle
- Offline cache: bookmarks persisted to ApplicationSupport JSON and shown
  instantly on launch; cache is per-server, skipped when unread filter is on
- Unread filter: toolbar toggle sends ?unread=true to the API; title updates
  to "Unread"; no stale-cache flash when toggling
- Extract normalizedURL and parsedTags into String+Helpers, removing three
  copies of URL normalization and two of tag parsing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:51:54 -05:00

53 lines
1.5 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)
let claude = ClaudeService.load()
_viewModel = State(wrappedValue: BookmarksViewModel(api: api, claude: claude, 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)
}
}
}
}