ReadKeep/readeck/UI/readeckApp.swift
Ilyas Hallak 953ff5da8d feat: Implement persistent logout on 401 errors and hide TabBar in detail views
- Add AppViewModel to manage app-level state and handle 401 responses
- Implement automatic logout when API returns 401 Unauthorized
- Add persistent logout state using existing hasFinishedSetup flag
- Move NavigationStack outside TabView to enable automatic TabBar hiding
- Update API classes to send UnauthorizedAPIResponse notifications
- TabBar now hides automatically when navigating to detail views
2025-08-27 22:04:37 +02:00

54 lines
1.4 KiB
Swift

//
// readeckApp.swift
// readeck
//
// Created by Ilyas Hallak on 10.06.25.
//
import SwiftUI
import netfox
@main
struct readeckApp: App {
@StateObject private var appViewModel = AppViewModel()
@StateObject private var appSettings = AppSettings()
var body: some Scene {
WindowGroup {
Group {
if appViewModel.hasFinishedSetup {
MainTabView()
} else {
SettingsServerView()
.padding()
}
}
.environmentObject(appSettings)
.preferredColorScheme(appSettings.theme.colorScheme)
.onAppear {
#if DEBUG
NFX.sharedInstance().start()
#endif
// Initialize server connectivity monitoring
_ = ServerConnectivity.shared
Task {
await loadAppSettings()
}
}
.onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("SettingsChanged"))) { _ in
Task {
await loadAppSettings()
}
}
}
}
private func loadAppSettings() async {
let settingsRepository = SettingsRepository()
let settings = try? await settingsRepository.loadSettings()
await MainActor.run {
appSettings.settings = settings
}
}
}