fix: only add videos to watch history if playback started

This commit is contained in:
Bnyro 2023-08-04 18:08:50 +02:00
parent 1a78dd0475
commit b428b9073a

View File

@ -774,11 +774,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
fetchSponsorBlockSegments()
initializeChapters()
// add the video to the watch history
if (PlayerHelper.watchHistoryEnabled) {
DatabaseHelper.addToWatchHistory(videoId, streams)
}
}
}
}
@ -888,6 +883,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
BackgroundHelper.stopBackgroundPlay(requireContext())
}
// add the video to the watch history when starting to play the video
if (isPlaying && PlayerHelper.watchHistoryEnabled) {
lifecycleScope.launch(Dispatchers.IO) {
DatabaseHelper.addToWatchHistory(videoId, streams)
}
}
if (isPlaying && PlayerHelper.sponsorBlockEnabled) {
handler.postDelayed(
this@PlayerFragment::checkForSegments,