From 8d7bf62af7ab56486b4c9d03d9937d5d61dcf584 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sun, 16 Apr 2023 18:10:41 +0200 Subject: [PATCH] Add items to watch history when marking as watched --- .../github/libretube/ui/sheets/VideoOptionsBottomSheet.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 8fcbb498c..8af405d13 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 @@ -5,6 +5,7 @@ import androidx.navigation.fragment.NavHostFragment import com.github.libretube.R import com.github.libretube.api.RetrofitInstance import com.github.libretube.constants.PreferenceKeys +import com.github.libretube.db.DatabaseHelper import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.obj.WatchPosition import com.github.libretube.enums.ShareObjectType @@ -97,6 +98,11 @@ class VideoOptionsBottomSheet( val watchPosition = WatchPosition(videoId, Long.MAX_VALUE) withContext(Dispatchers.IO) { DatabaseHolder.Database.watchPositionDao().insert(watchPosition) + if (!PlayerHelper.watchHistoryEnabled) return@withContext + // add video to watch history + runCatching { + RetrofitInstance.api.getStreams(videoId) + }.getOrNull()?.let { DatabaseHelper.addToWatchHistory(videoId, it) } } if (PreferenceHelper.getBoolean(PreferenceKeys.HIDE_WATCHED_FROM_FEED, false)) { // get the host fragment containing the current fragment