Fixed: Opening ZIM file from history that does not exist in fileSystem leads to execpected UI behavior (When already a ZIM file opened in the reader).

* The issue occurs because we are not opening the zim file in the reader because it does not exist in the fileSystem but we are loading the saved URL in webView of that file which does not exist. So when we are switching between fragments then we are opening the previously saved zim file but with the wrong URL which leads to this unexpected behavior. So to fix this we are closing the previously opened book if the new zim file does not exist in the fileSystem.
This commit is contained in:
MohitMaliFtechiz 2024-03-21 18:19:55 +05:30 committed by Kelson
parent a0a0558ee8
commit 677a481ef5

View File

@ -113,6 +113,12 @@ class KiwixReaderFragment : CoreReaderFragment() {
)
if (filePath == null || !File(filePath).isFileExist()) {
// Close the previously opened book in the reader. Since this file is not found,
// it will not be set in the zimFileReader. The previously opened ZIM file
// will be saved when we move between fragments. If we return to the reader again,
// it will attempt to open the last opened ZIM file with the last loaded URL,
// which is inside the non-existing ZIM file. This leads to unexpected behavior.
exitBook()
activity.toast(R.string.error_file_not_found)
return
}