keep status state in thread view after refreshing (#2855)

* keep status state in thread view after refreshing

* add clarifying parentheses
This commit is contained in:
Konrad Pozniak 2022-11-18 21:03:51 +01:00 committed by GitHub
parent 199947ae04
commit 61a1baf533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -366,11 +366,12 @@ class ViewThreadViewModel @Inject constructor(
} }
private fun Status.toViewData(detailed: Boolean = false): StatusViewData.Concrete { private fun Status.toViewData(detailed: Boolean = false): StatusViewData.Concrete {
val oldStatus = (_uiState.value as? ThreadUiState.Success)?.statuses?.find { it.id == this.id }
return toViewData( return toViewData(
isShowingContent = alwaysShowSensitiveMedia || !actionableStatus.sensitive, isShowingContent = oldStatus?.isShowingContent ?: (alwaysShowSensitiveMedia || !actionableStatus.sensitive),
isExpanded = alwaysOpenSpoiler, isExpanded = oldStatus?.isExpanded ?: alwaysOpenSpoiler,
isCollapsed = !detailed, isCollapsed = oldStatus?.isCollapsed ?: !detailed,
isDetailed = detailed isDetailed = oldStatus?.isDetailed ?: detailed
) )
} }