From 494f0f4efdb28f0885934c89a08cb46208c97a9f Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Wed, 22 Feb 2023 04:07:36 +0530 Subject: [PATCH] Update WatchPositionDao's insertAll() method to accept a List. --- .../main/java/com/github/libretube/db/dao/WatchPositionDao.kt | 2 +- .../main/java/com/github/libretube/helpers/BackupHelper.kt | 4 +--- .../main/java/com/github/libretube/services/BackgroundMode.kt | 2 +- .../java/com/github/libretube/ui/fragments/PlayerFragment.kt | 2 +- .../com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/github/libretube/db/dao/WatchPositionDao.kt b/app/src/main/java/com/github/libretube/db/dao/WatchPositionDao.kt index bcf3ebd36..6ccc5f8e2 100644 --- a/app/src/main/java/com/github/libretube/db/dao/WatchPositionDao.kt +++ b/app/src/main/java/com/github/libretube/db/dao/WatchPositionDao.kt @@ -15,7 +15,7 @@ interface WatchPositionDao { suspend fun findById(videoId: String): WatchPosition? @Insert(onConflict = OnConflictStrategy.REPLACE) - suspend fun insertAll(vararg watchPositions: WatchPosition) + suspend fun insertAll(watchPositions: List) @Query("DELETE FROM watchPosition") suspend fun deleteAll() diff --git a/app/src/main/java/com/github/libretube/helpers/BackupHelper.kt b/app/src/main/java/com/github/libretube/helpers/BackupHelper.kt index 5ce185fe8..08759760a 100644 --- a/app/src/main/java/com/github/libretube/helpers/BackupHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/BackupHelper.kt @@ -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( diff --git a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt index c9cb2b3e4..abd5e9865 100644 --- a/app/src/main/java/com/github/libretube/services/BackgroundMode.kt +++ b/app/src/main/java/com/github/libretube/services/BackgroundMode.kt @@ -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) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 810bf9dd5..06c7657db 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -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)) } } diff --git a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt index dbb2ea056..96b46cfa5 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt @@ -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