Merge pull request #810 from kiwix/809-macos-side-tab-should-update-after-unlinking-a-zim-file

Fix macOS unlink last ZIM file issue
This commit is contained in:
Kelson 2024-06-16 03:42:22 +02:00 committed by GitHub
commit dcc86ed284
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -95,7 +95,7 @@
"zim_file_missing_indicator.help" = "Zim file is missing.";
"library.zim_file_details.side_panel.message" = "Select a ZIM file to see detail";
"library.zim_file_details.side_panel.message" = "Select a ZIM file to see details";
"library.zim_file_context.main_page.label" = "Main Page";
"library.zim_file_context.random.label" = "Random Page";
"library.zim_file_context.copy_url" = "Copy URL";

View File

@ -25,6 +25,7 @@ struct ZimFilesOpened: View {
animation: .easeInOut
) private var zimFiles: FetchedResults<ZimFile>
@State private var isFileImporterPresented = false
@EnvironmentObject private var viewModel: LibraryViewModel
let dismiss: (() -> Void)? // iOS only
var body: some View {
@ -46,6 +47,9 @@ struct ZimFilesOpened: View {
Message(text: "zim_file_opened.overlay.no-opened.message".localized)
}
}
.onChange(of: zimFiles.count) { _ in
viewModel.selectedZimFile = zimFiles.first // makes sure we also nil out, if all ZIMs were unlinked
}
// not using OpenFileButton here, because it does not work on iOS/iPadOS 15 when this view is in a modal
.fileImporter(
isPresented: $isFileImporterPresented,