From 8058c4bc79a7168b84bc4546c919835f8e51ee2c Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sun, 15 Jan 2023 15:18:07 +0100 Subject: [PATCH] fix crash when user clicks url on in partially loaded thread (#3174) --- .../tusky/components/viewthread/ViewThreadViewModel.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt index 486eac66..181b2642 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/viewthread/ViewThreadViewModel.kt @@ -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 } }