From 269050bc6b4f8fa22d65d2097cc5ff17cd741415 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Fri, 10 Jan 2025 19:15:10 +0100 Subject: [PATCH] feat(LocalFeedRepository): fetch only enabled channel tabs Updates the local feed extraction to only fetch channel tabs that are enabled. This cuts down the amount of requests that are send, but ultimately not used. --- .../com/github/libretube/repo/LocalFeedRepository.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/repo/LocalFeedRepository.kt b/app/src/main/java/com/github/libretube/repo/LocalFeedRepository.kt index e364f7c98..597498438 100644 --- a/app/src/main/java/com/github/libretube/repo/LocalFeedRepository.kt +++ b/app/src/main/java/com/github/libretube/repo/LocalFeedRepository.kt @@ -6,6 +6,7 @@ import com.github.libretube.api.obj.StreamItem import com.github.libretube.constants.PreferenceKeys import com.github.libretube.db.DatabaseHolder import com.github.libretube.db.obj.SubscriptionsFeedItem +import com.github.libretube.enums.ContentFilter import com.github.libretube.extensions.parallelMap import com.github.libretube.helpers.NewPipeExtractorInstance import com.github.libretube.helpers.PreferenceHelper @@ -19,7 +20,13 @@ import java.time.Instant class LocalFeedRepository : FeedRepository { private val relevantTabs = - arrayOf(ChannelTabs.LIVESTREAMS, ChannelTabs.VIDEOS, ChannelTabs.SHORTS) + listOf( + ContentFilter.LIVESTREAMS to ChannelTabs.LIVESTREAMS, + ContentFilter.VIDEOS to ChannelTabs.VIDEOS, + ContentFilter.SHORTS to ChannelTabs.SHORTS + ).mapNotNull { (filter, tab) -> + if (filter.isEnabled) tab else null + }.toTypedArray() override suspend fun getFeed(forceRefresh: Boolean): List { val nowMillis = Instant.now().toEpochMilli()