Skip to content

Commit d34d34e

Browse files
authored
Merge pull request libre-tube#7009 from FineFindus/fix/all-caught-up-local
fix(SubscriptionsFragment): update lastFeedWatchedTime to latest video upload in feed
2 parents a5ef88a + 54835c9 commit d34d34e

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.content.SharedPreferences
55
import androidx.core.content.edit
66
import androidx.preference.PreferenceManager
77
import com.github.libretube.constants.PreferenceKeys
8-
import java.time.Instant
98

109
object PreferenceHelper {
1110
/**
@@ -105,8 +104,8 @@ object PreferenceHelper {
105104
return getString(PreferenceKeys.LAST_STREAM_VIDEO_ID, "")
106105
}
107106

108-
fun updateLastFeedWatchedTime() {
109-
putLong(PreferenceKeys.LAST_WATCHED_FEED_TIME, Instant.now().epochSecond)
107+
fun setLastFeedWatchedTime(time: Long) {
108+
putLong(PreferenceKeys.LAST_WATCHED_FEED_TIME, time)
110109
}
111110

112111
fun getLastCheckedFeedTime(): Long {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
379379
// add an "all caught up item"
380380
if (selectedSortOrder == 0) {
381381
val lastCheckedFeedTime = PreferenceHelper.getLastCheckedFeedTime()
382-
val caughtUpIndex = feed.indexOfFirst { it.uploaded / 1000 < lastCheckedFeedTime && !it.isUpcoming }
382+
val caughtUpIndex = feed.indexOfFirst { it.uploaded <= lastCheckedFeedTime && !it.isUpcoming }
383383
if (caughtUpIndex > 0) {
384384
sortedFeed.add(
385385
caughtUpIndex,
@@ -398,7 +398,9 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
398398

399399
binding.toggleSubs.text = getString(R.string.subscriptions)
400400

401-
PreferenceHelper.updateLastFeedWatchedTime()
401+
feed.firstOrNull { !it.isUpcoming }?.uploaded?.let {
402+
PreferenceHelper.setLastFeedWatchedTime(it)
403+
};
402404
}
403405

404406
@SuppressLint("SetTextI18n")

0 commit comments

Comments
 (0)