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 cc977cdae..03185de45 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 @@ -520,13 +520,17 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { // save the watch position if video isn't finished and option enabled private fun saveWatchPosition() { - if (PlayerHelper.watchPositionsEnabled && exoPlayer.currentPosition != exoPlayer.duration) { + if (!PlayerHelper.watchPositionsEnabled) return + if (exoPlayer.currentPosition != exoPlayer.duration) { + val watchPosition = WatchPosition(videoId!!, exoPlayer.currentPosition) query { - Database.watchPositionDao().insertAll(WatchPosition(videoId!!, exoPlayer.currentPosition)) + Database.watchPositionDao().insertAll(watchPosition) } } else if (PlayerHelper.watchPositionsEnabled) { // delete watch position if video has ended - Database.watchPositionDao().deleteById(videoId!!) + query { + Database.watchPositionDao().deleteById(videoId!!) + } } }