Fix crash when opening archived chats.

This commit is contained in:
Alex Hart
2025-10-20 14:43:24 -03:00
committed by Greyson Parrelli
parent 329389bb41
commit 1b2e80d2c8
3 changed files with 12 additions and 5 deletions

View File

@@ -137,7 +137,7 @@ private fun BoxScope.SecondaryActionButton(
} }
AnimatedVisibility( AnimatedVisibility(
visible = destination == MainNavigationListLocation.CHATS, visible = destination == MainNavigationListLocation.CHATS || destination == MainNavigationListLocation.ARCHIVE,
modifier = Modifier.align(secondaryButtonAlignment), modifier = Modifier.align(secondaryButtonAlignment),
enter = slideInVertically(initialOffsetY = offsetYProvider), enter = slideInVertically(initialOffsetY = offsetYProvider),
exit = slideOutVertically(targetOffsetY = offsetYProvider) exit = slideOutVertically(targetOffsetY = offsetYProvider)
@@ -170,7 +170,7 @@ private fun PrimaryActionButton(
) { ) {
val onClick = remember(destination) { val onClick = remember(destination) {
when (destination) { when (destination) {
MainNavigationListLocation.ARCHIVE -> error("Not supported") MainNavigationListLocation.ARCHIVE -> onNewChatClick
MainNavigationListLocation.CHATS -> onNewChatClick MainNavigationListLocation.CHATS -> onNewChatClick
MainNavigationListLocation.CALLS -> onNewCallClick MainNavigationListLocation.CALLS -> onNewCallClick
MainNavigationListLocation.STORIES -> { MainNavigationListLocation.STORIES -> {
@@ -185,7 +185,7 @@ private fun PrimaryActionButton(
icon = { icon = {
AnimatedContent(destination) { targetState -> AnimatedContent(destination) { targetState ->
val (icon, contentDescriptionId) = when (targetState) { val (icon, contentDescriptionId) = when (targetState) {
MainNavigationListLocation.ARCHIVE -> error("Not supported") MainNavigationListLocation.ARCHIVE -> R.drawable.symbol_edit_24 to R.string.conversation_list_fragment__fab_content_description
MainNavigationListLocation.CHATS -> R.drawable.symbol_edit_24 to R.string.conversation_list_fragment__fab_content_description MainNavigationListLocation.CHATS -> R.drawable.symbol_edit_24 to R.string.conversation_list_fragment__fab_content_description
MainNavigationListLocation.CALLS -> R.drawable.symbol_phone_plus_24 to R.string.CallLogFragment__start_a_new_call MainNavigationListLocation.CALLS -> R.drawable.symbol_phone_plus_24 to R.string.CallLogFragment__start_a_new_call
MainNavigationListLocation.STORIES -> R.drawable.symbol_camera_24 to R.string.conversation_list_fragment__open_camera_description MainNavigationListLocation.STORIES -> R.drawable.symbol_camera_24 to R.string.conversation_list_fragment__open_camera_description

View File

@@ -230,8 +230,14 @@ fun MainNavigationRail(
} }
} }
val selectedDestination = if (state.currentListLocation == MainNavigationListLocation.ARCHIVE) {
MainNavigationListLocation.CHATS
} else {
state.currentListLocation
}
entries.forEachIndexed { idx, destination -> entries.forEachIndexed { idx, destination ->
val selected = state.currentListLocation == destination val selected = selectedDestination == destination
Box { Box {
NavigationRailItem( NavigationRailItem(

View File

@@ -20,6 +20,7 @@
android:id="@+id/recycler" android:id="@+id/recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:background="@color/signal_colorBackground"
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false" android:clipToPadding="false"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -50,6 +51,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inflatedId="@+id/banner_compose_view" android:inflatedId="@+id/banner_compose_view"
android:layout="@layout/conversation_list_banner_view" android:layout="@layout/conversation_list_banner_view"
app:layout_constraintTop_toTopOf="@id/recycler"/> app:layout_constraintTop_toTopOf="@id/recycler" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>