Skip to content

Commit 805d1f2

Browse files
authored
Merge pull request libre-tube#7320 from FineFindus/fix/update-last-watchtime
fix(Feed): only update `LastFeedWatchedTime` when update time is newer
2 parents c0ead84 + 8645bfc commit 805d1f2

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

app/src/main/java/com/github/libretube/helpers/PreferenceHelper.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ object PreferenceHelper {
104104
return getString(PreferenceKeys.LAST_STREAM_VIDEO_ID, "")
105105
}
106106

107-
fun setLastFeedWatchedTime(time: Long) {
108-
putLong(PreferenceKeys.LAST_WATCHED_FEED_TIME, time)
107+
fun updateLastFeedWatchedTime(time: Long) {
108+
// only update the time if the time is newer
109+
// this avoids cases, where the user last saw an older video, which had already been seen,
110+
// causing all following video to be incorrectly marked as unseen again
111+
if (getLastCheckedFeedTime() < time)
112+
putLong(PreferenceKeys.LAST_WATCHED_FEED_TIME, time)
109113
}
110114

111115
fun getLastCheckedFeedTime(): Long {

app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
398398
binding.toggleSubs.text = getString(R.string.subscriptions)
399399

400400
feed.firstOrNull { !it.isUpcoming }?.uploaded?.let {
401-
PreferenceHelper.setLastFeedWatchedTime(it)
401+
PreferenceHelper.updateLastFeedWatchedTime(it)
402402
}
403403

404404
binding.subRefresh.isRefreshing = false

0 commit comments

Comments
 (0)