Fix local favorites list jumping (#206)
* Revert "Fix local favorites scroll state loss"
This reverts commit c4be269f
* Enable placeholders as workaround
* Remove TODO
* Bump minimum fast scroller handler height to 48 dp
Make it consistent with `VerticalFastScroller`
This commit is contained in:
1 parent
1293d7fe28
commit
afa2d03b56
5 files changed
+7
-18
No files matched your search
@@ -38,13 +38,8 @@ import splitties.arch.room.roomDb
|
||||
object EhDB {
|
||||
private val db = roomDb<EhDatabase>("eh.db")
|
||||
|
||||
private suspend fun putGalleryInfo(galleryInfo: BaseGalleryInfo, update: Boolean = false) {
|
||||
val dao = db.galleryDao()
|
||||
if (update) {
|
||||
dao.upsert(galleryInfo)
|
||||
} else {
|
||||
dao.insertOrIgnore(galleryInfo)
|
||||
}
|
||||
private suspend fun putGalleryInfo(galleryInfo: BaseGalleryInfo) {
|
||||
db.galleryDao().upsert(galleryInfo)
|
||||
}
|
||||
|
||||
private suspend fun deleteGalleryInfo(galleryInfo: BaseGalleryInfo) {
|
||||
@@ -195,8 +190,8 @@ object EhDB {
|
||||
|
||||
fun searchLocalFav(keyword: String) = db.localFavoritesDao().joinListLazy("%$keyword%")
|
||||
|
||||
suspend fun putHistoryInfo(galleryInfo: BaseGalleryInfo, updateGalleryInfo: Boolean = false) {
|
||||
putGalleryInfo(galleryInfo, updateGalleryInfo)
|
||||
suspend fun putHistoryInfo(galleryInfo: BaseGalleryInfo) {
|
||||
putGalleryInfo(galleryInfo)
|
||||
db.historyDao().upsert(HistoryInfo(galleryInfo.gid))
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,6 @@ interface GalleryDao {
|
||||
@Query("SELECT * FROM GALLERIES")
|
||||
suspend fun list(): List<BaseGalleryInfo>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
suspend fun insertOrIgnore(galleryInfo: BaseGalleryInfo)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
suspend fun insertOrIgnore(galleryInfoList: List<BaseGalleryInfo>)
|
||||
|
||||
|
||||
@@ -331,6 +331,6 @@ class FastScroller : View {
|
||||
private const val INVALID = -1
|
||||
private const val SCROLL_BAR_FADE_DURATION = 500
|
||||
private const val SCROLL_BAR_DELAY = 1000
|
||||
private const val MIN_HANDLER_HEIGHT_DP = 32
|
||||
private const val MIN_HANDLER_HEIGHT_DP = 48
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class VMStorage : ViewModel() {
|
||||
}
|
||||
}.flow.cachedIn(viewModelScope)
|
||||
|
||||
private val localFavDataFlow = Pager(PagingConfig(20, enablePlaceholders = false, jumpThreshold = 40)) {
|
||||
private val localFavDataFlow = Pager(PagingConfig(20, jumpThreshold = 40)) {
|
||||
val keyword = urlBuilder.keyword
|
||||
if (keyword.isNullOrBlank()) {
|
||||
EhDB.localFavLazyList
|
||||
|
||||
@@ -292,10 +292,7 @@ fun GalleryDetailScreen(args: GalleryDetailScreenArgs, navigator: NavController)
|
||||
}
|
||||
}
|
||||
galleryInfo?.let {
|
||||
// Don't update gallery info in database if previous destination is favorites,
|
||||
// since it will invalidate local favorites PagingSource and lose scroll state
|
||||
val previousDestinationId = navigator.previousBackStackEntry?.destination?.id
|
||||
EhDB.putHistoryInfo(it.findBaseInfo(), previousDestinationId != R.id.nav_favourite)
|
||||
EhDB.putHistoryInfo(it.findBaseInfo())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user