Skip to content

Commit

Permalink
Implemented filter in FeedLoadManager.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel de Haan committed Oct 27, 2024
1 parent eb9f300 commit 9809630
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,15 @@ class FeedFragment : BaseStateFragment<FeedState>() {
val dialogItems = arrayOf(
getString(R.string.feed_show_watched),
getString(R.string.feed_show_partially_watched),
getString(R.string.feed_show_upcoming)
getString(R.string.feed_show_upcoming),
getString(R.string.feed_show_shorts)
)

val checkedDialogItems = booleanArrayOf(
viewModel.getShowPlayedItemsFromPreferences(),
viewModel.getShowPartiallyPlayedItemsFromPreferences(),
viewModel.getShowFutureItemsFromPreferences()
viewModel.getShowFutureItemsFromPreferences(),
viewModel.getShowShortsFromPreferences()
)

AlertDialog.Builder(context!!)
Expand All @@ -262,6 +264,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
viewModel.setSaveShowPlayedItems(checkedDialogItems[0])
viewModel.setSaveShowPartiallyPlayedItems(checkedDialogItems[1])
viewModel.setSaveShowFutureItems(checkedDialogItems[2])
viewModel.setSaveShowShorts(checkedDialogItems[3])
}
.setNegativeButton(R.string.cancel, null)
.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ class FeedLoadManager(private val context: Context) {
FeedUpdateInfo(
subscriptionEntity,
originalInfo!!,
streams!!,
streams!!.filter {
defaultSharedPreferences
.getBoolean(context.getString(R.string.feed_show_shorts_items_key), true)
||!it.isShortFormContent
},
errors,
)
)
Expand Down Expand Up @@ -260,7 +264,6 @@ class FeedLoadManager(private val context: Context) {
override fun accept(item: Notification<FeedUpdateInfo>) {
currentProgress.incrementAndGet()
notificationUpdater.onNext(item.value?.name.orEmpty())

broadcastProgress()
}
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -857,4 +857,6 @@
<string name="show_more">Show more</string>
<string name="show_less">Show less</string>
<string name="import_settings_vulnerable_format">The settings in the export being imported use a vulnerable format that was deprecated since NewPipe 0.27.0. Make sure the export being imported is from a trusted source, and prefer using only exports obtained from NewPipe 0.27.0 or newer in the future. Support for importing settings in this vulnerable format will soon be removed completely, and then old versions of NewPipe will not be able to import settings of exports from new versions anymore.</string>
<string name="feed_show_shorts_items_key">feed_show_shorts_items</string>
<string name="feed_show_shorts">Shorts (streams under 60 seconds)</string>
</resources>

0 comments on commit 9809630

Please sign in to comment.