fix crash when user clicks url on in partially loaded thread (#3174)

This commit is contained in:
Konrad Pozniak 2023-01-15 15:18:07 +01:00 committed by GitHub
parent 2df6a83e42
commit 8058c4bc79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -180,8 +180,12 @@ class ViewThreadViewModel @Inject constructor(
}
fun detailedStatus(): StatusViewData.Concrete? {
return (_uiState.value as ThreadUiState.Success?)?.statusViewData?.find { status ->
status.isDetailed
return when (val uiState = _uiState.value) {
is ThreadUiState.Success -> uiState.statusViewData.find { status ->
status.isDetailed
}
is ThreadUiState.LoadingThread -> uiState.statusViewDatum
else -> null
}
}