refactor: rename `filterAction` property to `contentFilterAction` (#1107)

`IStatusViewData.filterAction` was the `FilterAction` to apply to the
status based on the status' content.

As new filter options will apply filters based on the account that sent
the status, rename to `contentFilterAction` so it's easy to distinguish
between the two.
This commit is contained in:
Nik Clayton 2024-11-17 13:28:24 +01:00 committed by GitHub
parent ac63e5b7c7
commit 313cf7b26b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 22 additions and 22 deletions

View File

@ -50,7 +50,7 @@ open class FilterableStatusViewHolder<T : IStatusViewData>(
status: T, status: T,
listener: StatusActionListener<T>, listener: StatusActionListener<T>,
) { ) {
if (status.filterAction !== FilterAction.WARN) { if (status.contentFilterAction !== FilterAction.WARN) {
matchedFilter = null matchedFilter = null
setPlaceholderVisibility(false) setPlaceholderVisibility(false)
return return

View File

@ -52,7 +52,7 @@ open class StatusViewHolder<T : IStatusViewData>(
val expanded = viewData.isExpanded val expanded = viewData.isExpanded
setupCollapsedState(pachliAccountId, viewData, sensitive, expanded, listener) setupCollapsedState(pachliAccountId, viewData, sensitive, expanded, listener)
val reblogging = viewData.rebloggingStatus val reblogging = viewData.rebloggingStatus
if (reblogging == null || viewData.filterAction === FilterAction.WARN) { if (reblogging == null || viewData.contentFilterAction === FilterAction.WARN) {
statusInfo.hide() statusInfo.hide()
} else { } else {
val rebloggedByDisplayName = reblogging.account.name val rebloggedByDisplayName = reblogging.account.name

View File

@ -636,7 +636,7 @@ class NotificationsFragment :
adapter.snapshot().withIndex().filter { it.value?.statusViewData?.actionableId == viewData.statusViewData!!.actionableId } adapter.snapshot().withIndex().filter { it.value?.statusViewData?.actionableId == viewData.statusViewData!!.actionableId }
.map { .map {
it.value?.statusViewData = it.value?.statusViewData?.copy( it.value?.statusViewData = it.value?.statusViewData?.copy(
filterAction = FilterAction.NONE, contentFilterAction = FilterAction.NONE,
) )
adapter.notifyItemChanged(it.index) adapter.notifyItemChanged(it.index)
} }

View File

@ -133,7 +133,7 @@ class NotificationsPagingAdapter(
override fun getItemViewType(position: Int): Int { override fun getItemViewType(position: Int): Int {
val item = getItem(position) val item = getItem(position)
if (item?.statusViewData?.filterAction == FilterAction.WARN) { if (item?.statusViewData?.contentFilterAction == FilterAction.WARN) {
return NotificationViewKind.STATUS_FILTERED.ordinal return NotificationViewKind.STATUS_FILTERED.ordinal
} }

View File

@ -537,11 +537,11 @@ class NotificationsViewModel @AssistedInject constructor(
!(notification.status?.actionableStatus?.sensitive ?: false), !(notification.status?.actionableStatus?.sensitive ?: false),
isExpanded = statusDisplayOptions.value.openSpoiler, isExpanded = statusDisplayOptions.value.openSpoiler,
isCollapsed = true, isCollapsed = true,
filterAction = filterAction, contentFilterAction = filterAction,
isAboutSelf = notification.account.id == accountId, isAboutSelf = notification.account.id == accountId,
) )
}.filter { }.filter {
it.statusViewData?.filterAction != FilterAction.HIDE it.statusViewData?.contentFilterAction != FilterAction.HIDE
} }
} }
} }

View File

@ -80,7 +80,7 @@ class TimelinePagingAdapter(
override fun getItemViewType(position: Int): Int { override fun getItemViewType(position: Int): Int {
val viewData = getItem(position) ?: return VIEW_TYPE_PLACEHOLDER val viewData = getItem(position) ?: return VIEW_TYPE_PLACEHOLDER
return if (viewData.filterAction == FilterAction.WARN) { return if (viewData.contentFilterAction == FilterAction.WARN) {
VIEW_TYPE_STATUS_FILTERED VIEW_TYPE_STATUS_FILTERED
} else { } else {
VIEW_TYPE_STATUS VIEW_TYPE_STATUS

View File

@ -552,8 +552,8 @@ abstract class TimelineViewModel(
) { ) {
return FilterAction.HIDE return FilterAction.HIDE
} else { } else {
statusViewData.filterAction = contentFilterModel?.filterActionFor(status.actionableStatus) ?: FilterAction.NONE statusViewData.contentFilterAction = contentFilterModel?.filterActionFor(status.actionableStatus) ?: FilterAction.NONE
statusViewData.filterAction statusViewData.contentFilterAction
} }
} }

View File

@ -63,7 +63,7 @@ class ThreadAdapter(
val viewData = getItem(position) val viewData = getItem(position)
return if (viewData.isDetailed) { return if (viewData.isDetailed) {
VIEW_TYPE_STATUS_DETAILED VIEW_TYPE_STATUS_DETAILED
} else if (viewData.filterAction == FilterAction.WARN) { } else if (viewData.contentFilterAction == FilterAction.WARN) {
VIEW_TYPE_STATUS_FILTERED VIEW_TYPE_STATUS_FILTERED
} else { } else {
VIEW_TYPE_STATUS VIEW_TYPE_STATUS

View File

@ -552,8 +552,8 @@ class ViewThreadViewModel @Inject constructor(
if (status.isDetailed) { if (status.isDetailed) {
true true
} else { } else {
status.filterAction = contentFilterModel?.filterActionFor(status.status) ?: FilterAction.NONE status.contentFilterAction = contentFilterModel?.filterActionFor(status.status) ?: FilterAction.NONE
status.filterAction != FilterAction.HIDE status.contentFilterAction != FilterAction.HIDE
} }
} }
} }

View File

@ -60,7 +60,7 @@ data class NotificationViewData(
isShowingContent: Boolean, isShowingContent: Boolean,
isExpanded: Boolean, isExpanded: Boolean,
isCollapsed: Boolean, isCollapsed: Boolean,
filterAction: FilterAction, contentFilterAction: FilterAction,
isAboutSelf: Boolean, isAboutSelf: Boolean,
) = NotificationViewData( ) = NotificationViewData(
notification.type, notification.type,
@ -72,7 +72,7 @@ data class NotificationViewData(
isShowingContent, isShowingContent,
isExpanded, isExpanded,
isCollapsed, isCollapsed,
filterAction = filterAction, contentFilterAction = contentFilterAction,
) )
}, },
notification.report, notification.report,
@ -116,10 +116,10 @@ data class NotificationViewData(
get() = statusViewData?.actionableId ?: throw IllegalStateException() get() = statusViewData?.actionableId ?: throw IllegalStateException()
override val rebloggingStatus: Status? override val rebloggingStatus: Status?
get() = statusViewData?.rebloggingStatus get() = statusViewData?.rebloggingStatus
override var filterAction: FilterAction override var contentFilterAction: FilterAction
get() = statusViewData?.filterAction ?: throw IllegalStateException() get() = statusViewData?.contentFilterAction ?: throw IllegalStateException()
set(value) { set(value) {
statusViewData?.filterAction = value statusViewData?.contentFilterAction = value
} }
override val translationState: TranslationState override val translationState: TranslationState
get() = statusViewData?.translationState ?: throw IllegalStateException() get() = statusViewData?.translationState ?: throw IllegalStateException()

View File

@ -107,8 +107,8 @@ interface IStatusViewData {
// empty (e.g., StatusBaseViewHolder.setupFilterPlaceholder()). It would be better // empty (e.g., StatusBaseViewHolder.setupFilterPlaceholder()). It would be better
// if the Filter.Action class subtypes carried the FilterResult information with them, // if the Filter.Action class subtypes carried the FilterResult information with them,
// and it's impossible to construct them with an empty list. // and it's impossible to construct them with an empty list.
/** Whether this status should be filtered, and if so, how */ /** The [FilterAction] to apply, based on the status' content. */
var filterAction: FilterAction var contentFilterAction: FilterAction
/** The current translation state */ /** The current translation state */
val translationState: TranslationState val translationState: TranslationState
@ -123,7 +123,7 @@ data class StatusViewData(
override val isExpanded: Boolean, override val isExpanded: Boolean,
override val isShowingContent: Boolean, override val isShowingContent: Boolean,
override val isCollapsed: Boolean, override val isCollapsed: Boolean,
override var filterAction: FilterAction = FilterAction.NONE, override var contentFilterAction: FilterAction = FilterAction.NONE,
override val translationState: TranslationState, override val translationState: TranslationState,
/** /**
@ -202,7 +202,7 @@ data class StatusViewData(
isExpanded: Boolean, isExpanded: Boolean,
isCollapsed: Boolean, isCollapsed: Boolean,
isDetailed: Boolean = false, isDetailed: Boolean = false,
filterAction: FilterAction = FilterAction.NONE, contentFilterAction: FilterAction = FilterAction.NONE,
translationState: TranslationState = TranslationState.SHOW_ORIGINAL, translationState: TranslationState = TranslationState.SHOW_ORIGINAL,
translation: TranslatedStatusEntity? = null, translation: TranslatedStatusEntity? = null,
): StatusViewData { ): StatusViewData {
@ -223,7 +223,7 @@ data class StatusViewData(
isCollapsed = isCollapsed, isCollapsed = isCollapsed,
isExpanded = isExpanded, isExpanded = isExpanded,
isDetailed = isDetailed, isDetailed = isDetailed,
filterAction = filterAction, contentFilterAction = contentFilterAction,
translationState = translationState, translationState = translationState,
translation = translation, translation = translation,
) )