Reattach after slight delay instead on every db update (#5956)

(cherry picked from commit 1ae0d1b5d0028d297b34eb9d72b6a32885eadfee)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt
This commit is contained in:
Andreas 2021-09-24 00:45:55 +02:00 committed by Jobobby04
parent b2ee3bf176
commit fef5578a17

View File

@ -63,9 +63,12 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.sample
import reactivecircus.flowbinding.android.view.clicks
import reactivecircus.flowbinding.viewpager.pageSelections
import rx.Observable
import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.util.concurrent.TimeUnit
class LibraryController(
bundle: Bundle? = null,
@ -232,8 +235,10 @@ class LibraryController(
is LibrarySettingsSheet.Filter.FilterGroup -> onFilterChanged()
is LibrarySettingsSheet.Sort.SortGroup -> onSortChanged()
is LibrarySettingsSheet.Display.DisplayGroup -> {
if (!preferences.categorisedDisplaySettings().get() || activeCategory == 0) {
// Reattach adapter when flow preference change
val delay = if (preferences.categorisedDisplaySettings().get()) 125L else 0L
Observable.timer(delay, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
.subscribe {
reattachAdapter()
}
}
@ -338,11 +343,6 @@ class LibraryController(
.map { (it.id ?: -1) to (mangaMap[it.id]?.size ?: 0) }
.toMap()
/*if (preferences.categorisedDisplaySettings().get()) {
// Reattach adapter so it doesn't get de-synced
reattachAdapter()
}*/
// Restore active category.
binding.libraryPager.setCurrentItem(activeCat, false)