From 2c03bd91ef3be0a27335807e30d88fd42ce1672f Mon Sep 17 00:00:00 2001 From: "sergei.bakhtiarov" Date: Wed, 15 Jan 2025 17:29:17 +0100 Subject: [PATCH] fix: selection lost on update of share conversation list [#WPB-14911] --- .../ui/home/conversationslist/common/ConversationList.kt | 7 ++++--- .../android/ui/sharing/ImportMediaAuthenticatedState.kt | 4 ++-- .../ui/sharing/ImportMediaAuthenticatedViewModel.kt | 6 +++--- .../com/wire/android/ui/sharing/ImportMediaScreen.kt | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/common/ConversationList.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/common/ConversationList.kt index 9f768c8c4cc..ed4ac603686 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/common/ConversationList.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/common/ConversationList.kt @@ -67,7 +67,7 @@ fun ConversationList( modifier: Modifier = Modifier, lazyListState: LazyListState = rememberLazyListState(), isSelectableList: Boolean = false, - selectedConversations: List = emptyList(), + selectedConversations: List = emptyList(), onOpenConversation: (ConversationItem) -> Unit = {}, onEditConversation: (ConversationItem) -> Unit = {}, onOpenUserProfile: (UserId) -> Unit = {}, @@ -116,7 +116,7 @@ fun ConversationList( ConversationItemFactory( conversation = item, isSelectableItem = isSelectableList, - isChecked = selectedConversations.contains(item), + isChecked = selectedConversations.contains(item.conversationId), onConversationSelectedOnRadioGroup = { onConversationSelectedOnRadioGroup(item) }, openConversation = onOpenConversation, openMenu = onEditConversation, @@ -283,6 +283,7 @@ fun PreviewConversationListSelect() = WireTheme { ConversationList( lazyPagingConversations = previewConversationFoldersFlow(list = conversationFolders).collectAsLazyPagingItems(), isSelectableList = true, - selectedConversations = conversationFolders.filterIsInstance().filterIndexed { index, _ -> index % 3 == 0 }, + selectedConversations = conversationFolders.filterIsInstance().filterIndexed { index, _ -> index % 3 == 0 } + .map { it.conversationId }, ) } diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedState.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedState.kt index 83050a33fd1..ea7bae77252 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedState.kt @@ -20,7 +20,7 @@ package com.wire.android.ui.sharing import androidx.compose.runtime.Stable import androidx.paging.PagingData import com.wire.android.ui.home.conversationslist.model.ConversationFolderItem -import com.wire.android.ui.home.conversationslist.model.ConversationItem +import com.wire.kalium.logic.data.id.ConversationId import com.wire.kalium.logic.data.message.SelfDeletionTimer import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf @@ -33,7 +33,7 @@ data class ImportMediaAuthenticatedState( val importedText: String? = null, val isImporting: Boolean = false, val conversations: Flow> = emptyFlow(), - val selectedConversationItem: List = persistentListOf(), + val selectedConversationItem: List = persistentListOf(), val selfDeletingTimer: SelfDeletionTimer = SelfDeletionTimer.Enabled(null) ) { @Stable diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt index de0cfd71bfa..975eaa45366 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt @@ -132,7 +132,7 @@ class ImportMediaAuthenticatedViewModel @Inject constructor( viewModelScope.launch { with(conversationItem) { importMediaState = importMediaState.copy( - selectedConversationItem = listOf(this), + selectedConversationItem = listOf(this.conversationId), selfDeletingTimer = observeSelfDeletionSettingsForConversation( conversationId = conversationId, considerSelfUserSettings = true @@ -225,11 +225,11 @@ class ImportMediaAuthenticatedViewModel @Inject constructor( selfDeletingTimer = SelfDeletionTimer.Enabled(selfDeletionDuration.value) ) val logMap = importMediaState.selfDeletingTimer.toLogString( - "user timer update for conversationId=${it.conversationId.toLogString()} on ImportMediaScreen" + "user timer update for conversationId=${it.toLogString()} on ImportMediaScreen" ) appLogger.d("$SELF_DELETION_LOG_TAG: $logMap") persistNewSelfDeletionTimerUseCase( - conversationId = it.conversationId, + conversationId = it, newSelfDeletionTimer = importMediaState.selfDeletingTimer ) } diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt index b3276eabcd0..0d065b320a0 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaScreen.kt @@ -214,7 +214,7 @@ private fun ImportMediaAuthenticatedContent( NavigationCommand( ConversationScreenDestination( ConversationNavArgs( - conversationId = conversationItem.conversationId, + conversationId = conversationItem, pendingBundles = ArrayList(it), pendingTextBundle = importedText )