Remove selection when deleting file

This commit is contained in:
Christoph Hagen
2025-05-04 11:48:58 +02:00
parent cb041eb6ed
commit a8920a4cd2
2 changed files with 9 additions and 0 deletions

View File

@@ -29,4 +29,9 @@ final class SelectedContent: ObservableObject {
} }
} }
func remove(_ file: FileResource) {
if self.file == file {
self.file = nil
}
}
} }

View File

@@ -34,6 +34,9 @@ struct FileDetailView: View {
@EnvironmentObject @EnvironmentObject
private var content: Content private var content: Content
@EnvironmentObject
private var selection: SelectedContent
@Environment(\.language) @Environment(\.language)
private var language private var language
@@ -218,6 +221,7 @@ struct FileDetailView: View {
return return
} }
content.remove(file) content.remove(file)
selection.remove(file)
} }
} }