fix(Feed): only update LastFeedWatchedTime when update time is newer

Fixes an issue, where if the user switches between channel group,
already seen videos could be marked as new. This was caused by the
channel group having only older videos, which resetted the last watched
time to an older timepoint.
To fix this, the last watched time is only updated, when the new watched
time is newer than the previous watched time.
This commit is contained in:
FineFindus 2025-04-20 21:16:14 +02:00
parent c0ead845b2
commit 8645bfce29
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
2 changed files with 7 additions and 3 deletions

View File

@ -104,8 +104,12 @@ object PreferenceHelper {
return getString(PreferenceKeys.LAST_STREAM_VIDEO_ID, "") return getString(PreferenceKeys.LAST_STREAM_VIDEO_ID, "")
} }
fun setLastFeedWatchedTime(time: Long) { fun updateLastFeedWatchedTime(time: Long) {
putLong(PreferenceKeys.LAST_WATCHED_FEED_TIME, time) // only update the time if the time is newer
// this avoids cases, where the user last saw an older video, which had already been seen,
// causing all following video to be incorrectly marked as unseen again
if (getLastCheckedFeedTime() < time)
putLong(PreferenceKeys.LAST_WATCHED_FEED_TIME, time)
} }
fun getLastCheckedFeedTime(): Long { fun getLastCheckedFeedTime(): Long {

View File

@ -398,7 +398,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
binding.toggleSubs.text = getString(R.string.subscriptions) binding.toggleSubs.text = getString(R.string.subscriptions)
feed.firstOrNull { !it.isUpcoming }?.uploaded?.let { feed.firstOrNull { !it.isUpcoming }?.uploaded?.let {
PreferenceHelper.setLastFeedWatchedTime(it) PreferenceHelper.updateLastFeedWatchedTime(it)
} }
binding.subRefresh.isRefreshing = false binding.subRefresh.isRefreshing = false