Merge pull request #7009 from FineFindus/fix/all-caught-up-local

fix(SubscriptionsFragment): update lastFeedWatchedTime to latest video upload in feed
This commit is contained in:
Bnyro 2025-01-29 16:33:57 +01:00 committed by GitHub
commit d34d34e9e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -5,7 +5,6 @@ import android.content.SharedPreferences
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import com.github.libretube.constants.PreferenceKeys
import java.time.Instant
object PreferenceHelper {
/**
@ -105,8 +104,8 @@ object PreferenceHelper {
return getString(PreferenceKeys.LAST_STREAM_VIDEO_ID, "")
}
fun updateLastFeedWatchedTime() {
putLong(PreferenceKeys.LAST_WATCHED_FEED_TIME, Instant.now().epochSecond)
fun setLastFeedWatchedTime(time: Long) {
putLong(PreferenceKeys.LAST_WATCHED_FEED_TIME, time)
}
fun getLastCheckedFeedTime(): Long {

View File

@ -379,7 +379,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
// add an "all caught up item"
if (selectedSortOrder == 0) {
val lastCheckedFeedTime = PreferenceHelper.getLastCheckedFeedTime()
val caughtUpIndex = feed.indexOfFirst { it.uploaded / 1000 < lastCheckedFeedTime && !it.isUpcoming }
val caughtUpIndex = feed.indexOfFirst { it.uploaded <= lastCheckedFeedTime && !it.isUpcoming }
if (caughtUpIndex > 0) {
sortedFeed.add(
caughtUpIndex,
@ -398,7 +398,9 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub
binding.toggleSubs.text = getString(R.string.subscriptions)
PreferenceHelper.updateLastFeedWatchedTime()
feed.firstOrNull { !it.isUpcoming }?.uploaded?.let {
PreferenceHelper.setLastFeedWatchedTime(it)
};
}
@SuppressLint("SetTextI18n")