Skip to content

Commit

Permalink
fix: read conversation on short list
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Apr 12, 2024
2 parents bec868a + a2b700e commit f1f35b9
Show file tree
Hide file tree
Showing 28 changed files with 980 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
distribution: 'temurin'
cache: gradle
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2
uses: gradle/wrapper-validation-action@b231772637bb498f11fdbc86052b6e8a8dc9fc92
- name: Run Detekt
run: |
./gradlew detektAll
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle-run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2
uses: gradle/wrapper-validation-action@b231772637bb498f11fdbc86052b6e8a8dc9fc92

- name: AVD cache
uses: buildjet/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle-run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
cache: gradle

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2
uses: gradle/wrapper-validation-action@b231772637bb498f11fdbc86052b6e8a8dc9fc92

- name: Test Build Logic
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package com.wire.android.ui.home.conversations

import com.wire.android.ui.common.snackbar.SwipeableSnackbar
import android.annotation.SuppressLint
import android.net.Uri
import androidx.activity.compose.BackHandler
Expand Down Expand Up @@ -58,9 +57,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -100,9 +97,11 @@ import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.error.CoreFailureErrorDialog
import com.wire.android.ui.common.progress.WireCircularProgressIndicator
import com.wire.android.ui.common.snackbar.LocalSnackbarHostState
import com.wire.android.ui.common.snackbar.SwipeableSnackbar
import com.wire.android.ui.common.visbility.rememberVisibilityState
import com.wire.android.ui.destinations.ConversationScreenDestination
import com.wire.android.ui.destinations.GroupConversationDetailsScreenDestination
import com.wire.android.ui.destinations.ImagesPreviewScreenDestination
import com.wire.android.ui.destinations.InitiatingCallScreenDestination
import com.wire.android.ui.destinations.MediaGalleryScreenDestination
import com.wire.android.ui.destinations.MessageDetailsScreenDestination
Expand Down Expand Up @@ -161,6 +160,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch
import kotlinx.datetime.Instant
import kotlin.time.Duration.Companion.milliseconds
Expand Down Expand Up @@ -200,8 +200,8 @@ fun ConversationScreen(
) {
val coroutineScope = rememberCoroutineScope()
val uriHandler = LocalUriHandler.current
val resources = LocalContext.current.resources
val showDialog = remember { mutableStateOf(ConversationScreenDialogType.NONE) }
val focusManager = LocalFocusManager.current
val conversationScreenState = rememberConversationScreenState()
val messageComposerViewState = messageComposerViewModel.messageComposerViewState
val messageComposerStateHolder = rememberMessageComposerStateHolder(
Expand Down Expand Up @@ -340,6 +340,17 @@ fun ConversationScreen(
)
},
onSendMessage = sendMessageViewModel::trySendMessage,
onImagePicked = {
navigator.navigate(
NavigationCommand(
ImagesPreviewScreenDestination(
conversationId = conversationInfoViewModel.conversationInfoViewState.conversationId,
conversationName = conversationInfoViewModel.conversationInfoViewState.conversationName.asString(resources),
assetUri = it
)
)
)
},
onDeleteMessage = conversationMessagesViewModel::showDeleteMessageDialog,
onAssetItemClicked = conversationMessagesViewModel::downloadOrFetchAssetAndShowDialog,
onImageFullScreenMode = { message, isSelfMessage ->
Expand Down Expand Up @@ -392,7 +403,9 @@ fun ConversationScreen(
}
}
},
onBackButtonClick = { conversationScreenOnBackButtonClick(messageComposerViewModel, focusManager, navigator) },
onBackButtonClick = {
conversationScreenOnBackButtonClick(messageComposerViewModel, messageComposerStateHolder, navigator)
},
composerMessages = sendMessageViewModel.infoMessage,
conversationMessages = conversationMessagesViewModel.infoMessage,
conversationMessagesViewModel = conversationMessagesViewModel,
Expand Down Expand Up @@ -452,9 +465,10 @@ fun ConversationScreen(
}
}
},
onTypingEvent = messageComposerViewModel::sendTypingEvent
onTypingEvent = messageComposerViewModel::sendTypingEvent,
currentTimeInMillisFlow = conversationMessagesViewModel.currentTimeInMillisFlow
)
BackHandler { conversationScreenOnBackButtonClick(messageComposerViewModel, focusManager, navigator) }
BackHandler { conversationScreenOnBackButtonClick(messageComposerViewModel, messageComposerStateHolder, navigator) }
DeleteMessageDialog(
state = conversationMessagesViewModel.deleteMessageDialogsState,
actions = conversationMessagesViewModel.deleteMessageHelper
Expand Down Expand Up @@ -562,11 +576,11 @@ fun ConversationScreen(

private fun conversationScreenOnBackButtonClick(
messageComposerViewModel: MessageComposerViewModel,
focusManager: FocusManager,
messageComposerStateHolder: MessageComposerStateHolder,
navigator: Navigator
) {
messageComposerViewModel.sendTypingEvent(TypingIndicatorMode.STOPPED)
focusManager.clearFocus(true)
messageComposerStateHolder.messageCompositionInputStateHolder.collapseComposer(null)
navigator.navigateBack()
}

Expand Down Expand Up @@ -625,6 +639,7 @@ private fun ConversationScreen(
onOpenProfile: (String) -> Unit,
onMessageDetailsClick: (messageId: String, isSelfMessage: Boolean) -> Unit,
onSendMessage: (MessageBundle) -> Unit,
onImagePicked: (Uri) -> Unit,
onDeleteMessage: (String, Boolean) -> Unit,
onAudioClick: (String) -> Unit,
onChangeAudioPosition: (String, Int) -> Unit,
Expand All @@ -651,7 +666,8 @@ private fun ConversationScreen(
conversationScreenState: ConversationScreenState,
messageComposerStateHolder: MessageComposerStateHolder,
onLinkClick: (String) -> Unit,
onTypingEvent: (TypingIndicatorMode) -> Unit
onTypingEvent: (TypingIndicatorMode) -> Unit,
currentTimeInMillisFlow: Flow<Long> = flow { }
) {
val context = LocalContext.current
val snackbarHostState = LocalSnackbarHostState.current
Expand Down Expand Up @@ -740,6 +756,7 @@ private fun ConversationScreen(
messageComposerStateHolder = messageComposerStateHolder,
messages = conversationMessagesViewState.messages,
onSendMessage = onSendMessage,
onImagePicked = onImagePicked,
onAssetItemClicked = onAssetItemClicked,
onAudioItemClicked = onAudioClick,
onChangeAudioPosition = onChangeAudioPosition,
Expand All @@ -760,7 +777,8 @@ private fun ConversationScreen(
tempWritableVideoUri = tempWritableVideoUri,
onLinkClick = onLinkClick,
onTypingEvent = onTypingEvent,
onNavigateToReplyOriginalMessage = conversationMessagesViewModel::navigateToReplyOriginalMessage
onNavigateToReplyOriginalMessage = conversationMessagesViewModel::navigateToReplyOriginalMessage,
currentTimeInMillisFlow = currentTimeInMillisFlow
)
}
}
Expand All @@ -786,6 +804,7 @@ private fun ConversationScreenContent(
messageComposerStateHolder: MessageComposerStateHolder,
messages: Flow<PagingData<UIMessage>>,
onSendMessage: (MessageBundle) -> Unit,
onImagePicked: (Uri) -> Unit,
onAssetItemClicked: (String) -> Unit,
onAudioItemClicked: (String) -> Unit,
onChangeAudioPosition: (String, Int) -> Unit,
Expand All @@ -807,7 +826,8 @@ private fun ConversationScreenContent(
tempWritableVideoUri: Uri?,
onLinkClick: (String) -> Unit,
onTypingEvent: (TypingIndicatorMode) -> Unit,
onNavigateToReplyOriginalMessage: (UIMessage) -> Unit
onNavigateToReplyOriginalMessage: (UIMessage) -> Unit,
currentTimeInMillisFlow: Flow<Long> = flow {},
) {
val lazyPagingMessages = messages.collectAsLazyPagingItems()

Expand Down Expand Up @@ -842,6 +862,7 @@ private fun ConversationScreenContent(
selectedMessageId = selectedMessageId,
onNavigateToReplyOriginalMessage = onNavigateToReplyOriginalMessage,
interactionAvailability = messageComposerStateHolder.messageComposerViewState.value.interactionAvailability,
currentTimeInMillisFlow = currentTimeInMillisFlow
)
},
onChangeSelfDeletionClicked = onChangeSelfDeletionClicked,
Expand All @@ -851,7 +872,8 @@ private fun ConversationScreenContent(
onCaptureVideoPermissionPermanentlyDenied = onCaptureVideoPermissionPermanentlyDenied,
tempWritableVideoUri = tempWritableVideoUri,
tempWritableImageUri = tempWritableImageUri,
onTypingEvent = onTypingEvent
onTypingEvent = onTypingEvent,
onImagePicked = onImagePicked
)
}

Expand Down Expand Up @@ -914,6 +936,7 @@ fun MessageList(
selectedMessageId: String?,
onNavigateToReplyOriginalMessage: (UIMessage) -> Unit,
interactionAvailability: InteractionAvailability,
currentTimeInMillisFlow: Flow<Long> = flow { }
) {
val prevItemCount = remember { mutableStateOf(lazyPagingMessages.itemCount) }
val readLastMessageAtStartTriggered = remember { mutableStateOf(false) }
Expand Down Expand Up @@ -1015,6 +1038,7 @@ fun MessageList(
),
isSelectedMessage = (message.header.messageId == selectedMessageId),
isInteractionAvailable = interactionAvailability == InteractionAvailability.ENABLED,
currentTimeInMillisFlow = currentTimeInMillisFlow
)
}
}
Expand Down Expand Up @@ -1126,6 +1150,7 @@ fun PreviewConversationScreen() {
conversationScreenState = conversationScreenState,
messageComposerStateHolder = messageComposerStateHolder,
onLinkClick = { _ -> },
onTypingEvent = {}
onTypingEvent = {},
onImagePicked = {}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.ui.home.conversations.media.preview

import android.net.Uri
import com.wire.kalium.logic.data.id.ConversationId

data class ImagesPreviewNavArgs(
val conversationId: ConversationId,
val conversationName: String,
val assetUri: Uri
)
Loading

0 comments on commit f1f35b9

Please sign in to comment.