feat: Add a preference to hide "self-boosts"

A "self-boost" is someone boosting their own post. Some people are
particularly prolific at this, and it can clutter the timeline. Provide
a new preference that allows the user to show/hide these boosts from
their timeline.
This commit is contained in:
sanao 2023-10-24 05:47:11 +09:00 committed by GitHub
parent 42b09f4f1e
commit 1f2f4d51b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View File

@ -36,6 +36,14 @@ class TabFilterPreferencesFragment : PreferenceFragmentCompat() {
isIconSpaceReserved = false isIconSpaceReserved = false
} }
switchPreference {
setTitle(R.string.pref_title_show_self_boosts)
setSummary(R.string.pref_title_show_self_boosts_description)
key = PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS
setDefaultValue(true)
isIconSpaceReserved = false
}.apply { dependency = PrefKeys.TAB_FILTER_HOME_BOOSTS }
switchPreference { switchPreference {
setTitle(R.string.pref_title_show_replies) setTitle(R.string.pref_title_show_replies)
key = PrefKeys.TAB_FILTER_HOME_REPLIES key = PrefKeys.TAB_FILTER_HOME_REPLIES

View File

@ -301,6 +301,7 @@ abstract class TimelineViewModel(
private var filterRemoveReplies = false private var filterRemoveReplies = false
private var filterRemoveReblogs = false private var filterRemoveReblogs = false
private var filterRemoveSelfReblogs = false
protected val activeAccount = accountManager.activeAccount!! protected val activeAccount = accountManager.activeAccount!!
@ -397,6 +398,8 @@ abstract class TimelineViewModel(
!sharedPreferencesRepository.getBoolean(PrefKeys.TAB_FILTER_HOME_REPLIES, true) !sharedPreferencesRepository.getBoolean(PrefKeys.TAB_FILTER_HOME_REPLIES, true)
filterRemoveReblogs = filterRemoveReblogs =
!sharedPreferencesRepository.getBoolean(PrefKeys.TAB_FILTER_HOME_BOOSTS, true) !sharedPreferencesRepository.getBoolean(PrefKeys.TAB_FILTER_HOME_BOOSTS, true)
filterRemoveSelfReblogs =
!sharedPreferencesRepository.getBoolean(PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS, true)
} }
// Save the visible status ID (if it's the home timeline) // Save the visible status ID (if it's the home timeline)
@ -492,7 +495,9 @@ abstract class TimelineViewModel(
val status = statusViewData.status val status = statusViewData.status
return if ( return if (
(status.inReplyToId != null && filterRemoveReplies) || (status.inReplyToId != null && filterRemoveReplies) ||
(status.reblog != null && filterRemoveReblogs) (status.reblog != null && filterRemoveReblogs) ||
// To determine if the boost is boosting your own toot
((status.account.id == status.reblog?.account?.id) && filterRemoveSelfReblogs)
) { ) {
return Filter.Action.HIDE return Filter.Action.HIDE
} else { } else {
@ -560,6 +565,14 @@ abstract class TimelineViewModel(
reloadKeepingReadingPosition() reloadKeepingReadingPosition()
} }
} }
PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS -> {
val filter = sharedPreferencesRepository.getBoolean(PrefKeys.TAB_SHOW_HOME_SELF_BOOSTS, true)
val oldRemoveSelfReblogs = filterRemoveSelfReblogs
filterRemoveSelfReblogs = timelineKind is TimelineKind.Home && !filter
if (oldRemoveSelfReblogs != filterRemoveSelfReblogs) {
reloadKeepingReadingPosition()
}
}
} }
} }

View File

@ -103,6 +103,7 @@ object PrefKeys {
const val TAB_FILTER_HOME_REPLIES = "tabFilterHomeReplies_v2" // This was changed once to reset an unintentionally set default. const val TAB_FILTER_HOME_REPLIES = "tabFilterHomeReplies_v2" // This was changed once to reset an unintentionally set default.
const val TAB_FILTER_HOME_BOOSTS = "tabFilterHomeBoosts" const val TAB_FILTER_HOME_BOOSTS = "tabFilterHomeBoosts"
const val TAB_SHOW_HOME_SELF_BOOSTS = "tabShowHomeSelfBoosts"
/** UI text scaling factor, stored as float, 100 = 100% = no scaling */ /** UI text scaling factor, stored as float, 100 = 100% = no scaling */
const val UI_TEXT_SCALE_RATIO = "uiTextScaleRatio" const val UI_TEXT_SCALE_RATIO = "uiTextScaleRatio"

View File

@ -144,6 +144,8 @@
<string name="action_share_account_username">Share username of account</string> <string name="action_share_account_username">Share username of account</string>
<string name="action_hide_reblogs">Hide boosts</string> <string name="action_hide_reblogs">Hide boosts</string>
<string name="action_show_reblogs">Show boosts</string> <string name="action_show_reblogs">Show boosts</string>
<string name="pref_title_show_self_boosts">Show self-boosts</string>
<string name="pref_title_show_self_boosts_description">Someone boosting their own post</string>
<string name="action_report">Report</string> <string name="action_report">Report</string>
<string name="action_edit">Edit</string> <string name="action_edit">Edit</string>
<string name="action_delete">Delete</string> <string name="action_delete">Delete</string>