Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: empty conversation list on import media [WPB-10483] #3400

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class ImportMediaAuthenticatedViewModel @Inject constructor(
val searchQueryTextState: TextFieldState = TextFieldState()
var importMediaState by mutableStateOf(ImportMediaAuthenticatedState())
private set
var avatarAsset by mutableStateOf<ImageAsset.UserAvatarAsset?>(null)
private set

private val _infoMessage = MutableSharedFlow<SnackBarMessage>()
val infoMessage = _infoMessage.asSharedFlow()
Expand All @@ -113,10 +115,9 @@ class ImportMediaAuthenticatedViewModel @Inject constructor(
private fun loadUserAvatar() = viewModelScope.launch(dispatchers.io()) {
getSelf().collect { selfUser ->
withContext(dispatchers.main()) {
importMediaState =
importMediaState.copy(avatarAsset = selfUser.previewPicture?.let {
ImageAsset.UserAvatarAsset(wireSessionImageLoader, it)
})
avatarAsset = selfUser.previewPicture?.let {
ImageAsset.UserAvatarAsset(wireSessionImageLoader, it)
}
}
}
}
Expand All @@ -143,8 +144,10 @@ class ImportMediaAuthenticatedViewModel @Inject constructor(
}
.flowOn(dispatchers.io())
.collect { updatedState ->
importMediaState =
importMediaState.copy(shareableConversationListState = updatedState)
withContext(dispatchers.main()) {
importMediaState =
importMediaState.copy(shareableConversationListState = updatedState)
}
}
}

Expand Down Expand Up @@ -372,7 +375,6 @@ class ImportMediaAuthenticatedViewModel @Inject constructor(

@Stable
data class ImportMediaAuthenticatedState(
val avatarAsset: ImageAsset.UserAvatarAsset? = null,
val importedAssets: PersistentList<ImportedMediaAsset> = persistentListOf(),
val importedText: String? = null,
val isImporting: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.wire.android.R
import com.wire.android.model.Clickable
import com.wire.android.model.ImageAsset
import com.wire.android.model.SnackBarMessage
import com.wire.android.model.UserAvatarData
import com.wire.android.navigation.BackStackMode
Expand Down Expand Up @@ -188,12 +189,14 @@ private fun ImportMediaAuthenticatedContent(
if (isRestrictedInTeam) {
ImportMediaRestrictedContent(
importMediaAuthenticatedState = importMediaViewModel.importMediaState,
avatarAsset = null,
navigateBack = navigator.finish
)
} else {
ImportMediaRegularContent(
importMediaAuthenticatedState = importMediaViewModel.importMediaState,
searchQueryTextState = importMediaViewModel.searchQueryTextState,
avatarAsset = importMediaViewModel.avatarAsset,
onConversationClicked = importMediaViewModel::onConversationClicked,
checkRestrictionsAndSendImportedMedia = {
with(importMediaViewModel.importMediaState) {
Expand Down Expand Up @@ -243,6 +246,7 @@ private fun ImportMediaAuthenticatedContent(
@Composable
fun ImportMediaRestrictedContent(
importMediaAuthenticatedState: ImportMediaAuthenticatedState,
avatarAsset: ImageAsset.UserAvatarAsset?,
navigateBack: () -> Unit,
modifier: Modifier = Modifier,
) {
Expand Down Expand Up @@ -277,6 +281,7 @@ fun ImportMediaRestrictedContent(
@Composable
fun ImportMediaRegularContent(
importMediaAuthenticatedState: ImportMediaAuthenticatedState,
avatarAsset: ImageAsset.UserAvatarAsset?,
searchQueryTextState: TextFieldState,
onConversationClicked: (conversationId: ConversationId) -> Unit,
checkRestrictionsAndSendImportedMedia: () -> Unit,
Expand Down Expand Up @@ -629,6 +634,7 @@ fun PreviewImportMediaScreenRestricted() {
WireTheme {
ImportMediaRestrictedContent(
importMediaAuthenticatedState = ImportMediaAuthenticatedState(),
avatarAsset = null,
navigateBack = {}
)
}
Expand Down Expand Up @@ -687,6 +693,7 @@ fun PreviewImportMediaScreenRegular() {
)
),
),
avatarAsset = null,
searchQueryTextState = rememberTextFieldState(),
onConversationClicked = {},
checkRestrictionsAndSendImportedMedia = {},
Expand All @@ -709,6 +716,7 @@ fun PreviewImportMediaTextScreenRegular() {
"This is a second line with a veeeeeeeeeeeeeeeeeeeeeeeeeeery long shared text message"
),
searchQueryTextState = rememberTextFieldState(),
avatarAsset = null,
onConversationClicked = {},
checkRestrictionsAndSendImportedMedia = {},
onNewSelfDeletionTimerPicked = {},
Expand Down
Loading