From 1292c0eceac913532c093784f33fa42754ce6560 Mon Sep 17 00:00:00 2001 From: inorichi Date: Thu, 25 Jan 2018 19:59:10 +0100 Subject: [PATCH] Fix library query being lost --- .../tachiyomi/ui/library/LibraryController.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index e7f8f9a68..813f8b1e0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -118,6 +118,8 @@ class LibraryController( private var tabsVisibilitySubscription: Subscription? = null + private var searchViewSubscription: Subscription? = null + init { setHasOptionsMenu(true) retainViewMode = RetainViewMode.RETAIN_DETACH @@ -332,10 +334,14 @@ class LibraryController( // Mutate the filter icon because it needs to be tinted and the resource is shared. menu.findItem(R.id.action_filter).icon.mutate() - searchView.queryTextChanges().subscribeUntilDestroy { - query = it.toString() - searchRelay.call(query) - } + searchViewSubscription?.unsubscribe() + searchViewSubscription = searchView.queryTextChanges() + // Ignore events if this controller isn't at the top + .filter { router.backstack.lastOrNull()?.controller() == this } + .subscribeUntilDestroy { + query = it.toString() + searchRelay.call(query) + } searchItem.fixExpand() } @@ -518,4 +524,4 @@ class LibraryController( const val REQUEST_IMAGE_OPEN = 101 } -} \ No newline at end of file +}