Skip to content

Commit

Permalink
Merge pull request #4199 from kiwix/Fixes#4198
Browse files Browse the repository at this point in the history
Fixed: Search was not working when closing a tab and immediately opening the search screen.
  • Loading branch information
kelson42 authored Jan 31, 2025
2 parents 553fc44 + 8be4029 commit 3da8c40
Showing 1 changed file with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@ abstract class CoreReaderFragment :

override fun onDestroyView() {
super.onDestroyView()
restoreTabsSnackbarCallback = null
try {
coreReaderLifeCycleScope?.cancel()
readerLifeCycleScope?.cancel()
Expand Down Expand Up @@ -1394,17 +1395,7 @@ abstract class CoreReaderFragment :
.setAction(R.string.undo) { undoButton ->
undoButton.isEnabled = false
restoreDeletedTab(index)
}.addCallback(object : Snackbar.Callback() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
super.onDismissed(transientBottomBar, event)
// If the undo button is not clicked and no tabs are left, exit the book and
// clean up resources.
if (event != DISMISS_EVENT_ACTION && webViewList.isEmpty()) {
closeZimBook()
}
}
})
.show()
}.addCallback(restoreTabsSnackbarCallback).show()
}
openHomeScreen()
}
Expand Down Expand Up @@ -1895,16 +1886,18 @@ abstract class CoreReaderFragment :
setIsCloseAllTabButtonClickable(true)
restoreDeletedTabs()
}
}.addCallback(object : Snackbar.Callback() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
super.onDismissed(transientBottomBar, event)
// If the undo button is not clicked and no tabs are left, exit the book and
// clean up resources.
if (event != DISMISS_EVENT_ACTION && webViewList.isEmpty()) {
closeZimBook()
}
}
}).show()
}.addCallback(restoreTabsSnackbarCallback).show()
}
}

private var restoreTabsSnackbarCallback: Snackbar.Callback? = object : Snackbar.Callback() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
super.onDismissed(transientBottomBar, event)
// If the undo button is not clicked and no tabs are left, exit the book and
// clean up resources.
if (event != DISMISS_EVENT_ACTION && webViewList.isEmpty() && isAdded) {
closeZimBook()
}
}
}

Expand Down

0 comments on commit 3da8c40

Please sign in to comment.