File tree Expand file tree Collapse file tree
app/src/main/java/eu/darken/butler/workspace/ui/manager/preview Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
2424import kotlinx.coroutines.flow.launchIn
2525import kotlinx.coroutines.flow.map
2626import kotlinx.coroutines.flow.onEach
27+ import kotlinx.coroutines.flow.take
2728import javax.inject.Inject
2829import javax.inject.Singleton
2930
@@ -58,6 +59,19 @@ class WorkspacePreviewManager @Inject constructor(
5859 fun start () {
5960 log(TAG , INFO ) { " WorkspacePreviewRefreshManager started" }
6061
62+ // Check for orphaned previews on initialization
63+ workspaceRepo.state
64+ .map { it.infos.isEmpty() }
65+ .take(1 )
66+ .onEach { isEmpty ->
67+ if (isEmpty) {
68+ log(TAG , INFO ) { " No workspaces on initialization - clearing orphaned preview caches" }
69+ clearAllPreviewCaches()
70+ }
71+ }
72+ .catch { log(TAG , ERROR ) { " Failed to check for orphaned previews: ${it.asLog()} " } }
73+ .launchIn(appScope)
74+
6175 // Invalidate preview cache when workspace gains focus (for live preview)
6276 combine(
6377 workspacePageManager.state
You can’t perform that action at this time.
0 commit comments