mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Merge pull request #3154 from Isira-Seneviratne/Improve_WatchPositionDao
Improve WatchPositionDao.
This commit is contained in:
commit
d2e2d806b6
@ -1,7 +1,6 @@
|
||||
package com.github.libretube.db.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
@ -16,13 +15,7 @@ interface WatchPositionDao {
|
||||
suspend fun findById(videoId: String): WatchPosition?
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertAll(vararg watchPositions: WatchPosition)
|
||||
|
||||
@Delete
|
||||
suspend fun delete(watchPosition: WatchPosition)
|
||||
|
||||
@Query("DELETE FROM watchHistoryItem WHERE videoId = :videoId")
|
||||
suspend fun deleteById(videoId: String)
|
||||
suspend fun insertAll(watchPositions: List<WatchPosition>)
|
||||
|
||||
@Query("DELETE FROM watchPosition")
|
||||
suspend fun deleteAll()
|
||||
|
@ -48,9 +48,7 @@ object BackupHelper {
|
||||
|
||||
Database.watchHistoryDao().insertAll(backupFile.watchHistory.orEmpty())
|
||||
Database.searchHistoryDao().insertAll(backupFile.searchHistory.orEmpty())
|
||||
Database.watchPositionDao().insertAll(
|
||||
*backupFile.watchPositions.orEmpty().toTypedArray()
|
||||
)
|
||||
Database.watchPositionDao().insertAll(backupFile.watchPositions.orEmpty())
|
||||
Database.localSubscriptionDao().insertAll(backupFile.localSubscriptions.orEmpty())
|
||||
Database.customInstanceDao().insertAll(backupFile.customInstances.orEmpty())
|
||||
Database.playlistBookmarkDao().insertAll(
|
||||
|
@ -155,7 +155,7 @@ class BackgroundMode : LifecycleService() {
|
||||
this.streams ?: return@let
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
Database.watchPositionDao().insertAll(watchPosition)
|
||||
Database.watchPositionDao().insertAll(listOf(watchPosition))
|
||||
}
|
||||
}
|
||||
handler.postDelayed(this::updateWatchPosition, 500)
|
||||
|
@ -609,7 +609,7 @@ class PlayerFragment : Fragment(R.layout.fragment_player), OnlinePlayerOptions {
|
||||
if (!PlayerHelper.watchPositionsVideo) return
|
||||
val watchPosition = WatchPosition(videoId!!, exoPlayer.currentPosition)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
Database.watchPositionDao().insertAll(watchPosition)
|
||||
Database.watchPositionDao().insertAll(listOf(watchPosition))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ class VideoOptionsBottomSheet(
|
||||
getString(R.string.mark_as_watched) -> {
|
||||
val watchPosition = WatchPosition(videoId, Long.MAX_VALUE)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
DatabaseHolder.Database.watchPositionDao().insertAll(watchPosition)
|
||||
DatabaseHolder.Database.watchPositionDao().insertAll(listOf(watchPosition))
|
||||
}
|
||||
if (PreferenceHelper.getBoolean(PreferenceKeys.HIDE_WATCHED_FROM_FEED, false)) {
|
||||
// get the host fragment containing the current fragment
|
||||
|
Loading…
Reference in New Issue
Block a user