mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
Merge pull request #4950 from Bnyro/master
feat: hide watched videos from featured in homepage when enabled
This commit is contained in:
commit
51be2dfc9f
@ -35,6 +35,7 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.awaitAll
|
import kotlinx.coroutines.awaitAll
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
@ -143,13 +144,17 @@ class HomeFragment : Fragment() {
|
|||||||
SubscriptionHelper.getFeed()
|
SubscriptionHelper.getFeed()
|
||||||
}
|
}
|
||||||
}.getOrNull()?.takeIf { it.isNotEmpty() } ?: return
|
}.getOrNull()?.takeIf { it.isNotEmpty() } ?: return
|
||||||
}.filter {
|
}
|
||||||
|
var filteredFeed = feed.filter {
|
||||||
when (PreferenceHelper.getInt(PreferenceKeys.SELECTED_FEED_FILTER, 0)) {
|
when (PreferenceHelper.getInt(PreferenceKeys.SELECTED_FEED_FILTER, 0)) {
|
||||||
1 -> !it.isShort
|
1 -> !it.isShort
|
||||||
2 -> it.isShort
|
2 -> it.isShort
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}.take(20)
|
}
|
||||||
|
if (PreferenceHelper.getBoolean(PreferenceKeys.HIDE_WATCHED_FROM_FEED, false)) {
|
||||||
|
filteredFeed = runBlocking { DatabaseHelper.filterUnwatched(filteredFeed) }
|
||||||
|
}
|
||||||
val binding = _binding ?: return
|
val binding = _binding ?: return
|
||||||
|
|
||||||
makeVisible(binding.featuredRV, binding.featuredTV)
|
makeVisible(binding.featuredRV, binding.featuredTV)
|
||||||
@ -159,7 +164,7 @@ class HomeFragment : Fragment() {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
binding.featuredRV.adapter = VideosAdapter(
|
binding.featuredRV.adapter = VideosAdapter(
|
||||||
feed.toMutableList(),
|
filteredFeed.take(20).toMutableList(),
|
||||||
forceMode = VideosAdapter.Companion.ForceMode.HOME
|
forceMode = VideosAdapter.Companion.ForceMode.HOME
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user