Implement random walk in localFav
This commit is contained in:
1 parent
e22a39f549
commit
395a48ddeb
3 files changed
+16
No files matched your search
@@ -74,6 +74,8 @@ object EhDB {
|
||||
deleteGalleryInfo(downloadInfo.galleryInfo)
|
||||
}
|
||||
|
||||
suspend fun randomLocalFav() = db.localFavoritesDao().random()
|
||||
|
||||
suspend fun removeDownloadInfo(downloadInfo: List<DownloadInfo>) {
|
||||
val dao = db.downloadsDao()
|
||||
downloadInfo.forEach {
|
||||
|
||||
@@ -26,6 +26,10 @@ interface LocalFavoritesDao {
|
||||
@Query("SELECT * FROM LOCAL_FAVORITES JOIN GALLERIES USING(GID) WHERE TITLE LIKE :title ORDER BY TIME DESC")
|
||||
fun joinListLazy(title: String): PagingSource<Int, BaseGalleryInfo>
|
||||
|
||||
@RewriteQueriesToDropUnusedColumns
|
||||
@Query("SELECT * FROM LOCAL_FAVORITES JOIN GALLERIES USING(GID) ORDER BY RANDOM() DESC LIMIT 1")
|
||||
suspend fun random(): BaseGalleryInfo
|
||||
|
||||
@Query("SELECT EXISTS(SELECT * FROM LOCAL_FAVORITES WHERE GID = :gid)")
|
||||
suspend fun contains(gid: Long): Boolean
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.DoneAll
|
||||
import androidx.compose.material.icons.filled.Download
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material.icons.filled.Shuffle
|
||||
import androidx.compose.material.icons.outlined.FolderSpecial
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -84,6 +85,7 @@ import com.hippo.ehviewer.util.mapToLongArray
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import kotlin.math.roundToInt
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -338,6 +340,14 @@ fun FavouritesScreen(navigator: DestinationsNavigator) {
|
||||
autoCancel = !selectMode,
|
||||
) {
|
||||
if (!selectMode) {
|
||||
if (isLocalFav) {
|
||||
onClick(Icons.Default.Shuffle) {
|
||||
val random = EhDB.randomLocalFav()
|
||||
withUIContext {
|
||||
navigator.navigate(GalleryDetailScreenDestination(GalleryInfoArgs(random)))
|
||||
}
|
||||
}
|
||||
}
|
||||
onClick(EhIcons.Default.GoTo) {
|
||||
coroutineScope.launch {
|
||||
val date = dialogState.showDatePicker()
|
||||
|
||||
Reference in new issue
Block a user