ios: better backgrounding/resume

This commit is contained in:
2026-05-02 22:18:45 -07:00
parent cf9832ca3b
commit 4ad36d9bf6
7 changed files with 421 additions and 10 deletions
@@ -3,6 +3,8 @@ import SwiftUI
public struct SplitView: View {
@State private var viewModel = SybilViewModel()
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@Environment(\.scenePhase) private var scenePhase
@State private var shouldRefreshOnForeground = false
@MainActor public init() {
SybilFontRegistry.registerIfNeeded()
@@ -38,5 +40,26 @@ public struct SplitView: View {
.task {
await viewModel.bootstrap()
}
.onChange(of: scenePhase) { _, nextPhase in
switch nextPhase {
case .background:
shouldRefreshOnForeground = true
case .active:
guard shouldRefreshOnForeground, horizontalSizeClass != .compact else {
return
}
shouldRefreshOnForeground = false
Task {
await viewModel.refreshVisibleContent(
refreshCollections: true,
refreshSelection: viewModel.hasRefreshableSelection
)
}
case .inactive:
break
@unknown default:
break
}
}
}
}