-
Notifications
You must be signed in to change notification settings - Fork 314
Update message grouping to take time difference into account #6328
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
base: v7
Are you sure you want to change the base?
Changes from all commits
f3c62a3
46ff4be
24cfe81
b016d0c
6ccd9d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,10 +21,6 @@ import androidx.compose.foundation.layout.Row | |
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.LocalContext | ||
|
|
@@ -44,9 +40,6 @@ import io.getstream.chat.android.compose.ui.theme.ChatTheme | |
| import io.getstream.chat.android.compose.ui.theme.MessageFooterStatusIndicatorParams | ||
| import io.getstream.chat.android.compose.ui.theme.MessageStyling | ||
| import io.getstream.chat.android.compose.ui.theme.StreamTokens | ||
| import io.getstream.chat.android.compose.ui.util.clickable | ||
| import io.getstream.chat.android.core.utils.date.truncateFuture | ||
| import io.getstream.chat.android.models.Message | ||
| import io.getstream.chat.android.ui.common.state.messages.list.MessageItemState | ||
| import io.getstream.chat.android.ui.common.utils.extensions.shouldShowMessageStatusIndicator | ||
|
|
||
|
|
@@ -81,11 +74,10 @@ public fun MessageFooter( | |
| ) | ||
| } | ||
|
|
||
| if (messageItem.showMessageFooter) { | ||
| val showEditLabel = message.messageTextUpdatedAt != null && !message.isDeleted() | ||
| var showEditInfo by remember(message.id, showEditLabel) { mutableStateOf(false) } | ||
| val timestampStyle = MessageStyling.timestampStyle() | ||
| val showEditLabel = message.messageTextUpdatedAt != null && !message.isDeleted() | ||
| val timestampStyle = MessageStyling.timestampStyle() | ||
|
|
||
| if (messageItem.showMessageFooter) { | ||
| Row( | ||
| modifier = Modifier.padding(top = StreamTokens.spacingXs, bottom = StreamTokens.spacing2xs), | ||
| verticalAlignment = Alignment.CenterVertically, | ||
|
|
@@ -121,61 +113,27 @@ public fun MessageFooter( | |
| textStyle = timestampStyle, | ||
| ) | ||
| } | ||
| if (showEditLabel && !showEditInfo) { | ||
| if (showEditLabel) { | ||
| Text( | ||
| modifier = Modifier | ||
| .padding(start = StreamTokens.spacingXs) | ||
| .clickable { showEditInfo = !showEditInfo } | ||
| .testTag("Stream_MessageEditedLabel"), | ||
| text = LocalContext.current.getString(R.string.stream_compose_message_list_footnote_edited), | ||
| style = timestampStyle, | ||
| ) | ||
| } | ||
| } | ||
| if (showEditLabel && showEditInfo) { | ||
| Row( | ||
| modifier = Modifier | ||
| .padding(bottom = StreamTokens.spacing2xs) | ||
| .clickable { showEditInfo = !showEditInfo }, | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| ) { | ||
| Text( | ||
| modifier = Modifier | ||
| .padding(end = StreamTokens.spacing2xs) | ||
| .weight(1f, fill = false), | ||
| text = LocalContext.current.getString(R.string.stream_compose_message_list_footnote_edited), | ||
| style = timestampStyle, | ||
| overflow = TextOverflow.Ellipsis, | ||
| maxLines = 1, | ||
| ) | ||
| MessageEditedTimestamp(message = message) | ||
| } | ||
| } else if (showEditLabel) { | ||
| Row( | ||
| modifier = Modifier.padding(top = StreamTokens.spacingXs, bottom = StreamTokens.spacing2xs), | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| ) { | ||
| Text( | ||
| modifier = Modifier.testTag("Stream_MessageEditedLabel"), | ||
| text = LocalContext.current.getString(R.string.stream_compose_message_list_footnote_edited), | ||
| style = timestampStyle, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Composable function to display the timestamp for when a message was last edited. | ||
| * | ||
| * This function adjusts the `message.messageTextUpdatedAt` time to ensure it does not exceed the current system time. | ||
| * If the `messageTextUpdatedAt` time is slightly in the future, it resets the time to the current system time. | ||
| * | ||
| * @param message The message object containing the `messageTextUpdatedAt` timestamp. | ||
| * @param modifier Modifier for styling. | ||
| * @param formatType The type of formatting to provide. By default, it's [DateFormatType.RELATIVE]. | ||
| */ | ||
| @Composable | ||
| internal fun MessageEditedTimestamp( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Showing the edited timestamp is a feature that doesn't exist anymore in the new designs, so I'm also removing that |
||
| message: Message, | ||
| modifier: Modifier = Modifier, | ||
| formatType: DateFormatType = DateFormatType.RELATIVE, | ||
| ) { | ||
| val editedAt = message.messageTextUpdatedAt?.truncateFuture() | ||
| Timestamp( | ||
| date = editedAt, | ||
| modifier = modifier, | ||
| formatType = formatType, | ||
| textStyle = MessageStyling.timestampStyle(), | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,24 +35,10 @@ public sealed class MessageFooterVisibility { | |
| override fun toString(): String = "LastInGroup" | ||
| } | ||
|
|
||
| /** | ||
| * The message footer will be visible to items that are sent inside a specified time duration. | ||
| * | ||
| * @param timeDifferenceMillis Time duration after which we show the message footer. | ||
| */ | ||
| public data class WithTimeDifference( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in Slack, this now conflicted with the logic in
|
||
| val timeDifferenceMillis: Long = DEFAULT_FOOTER_TIME_DIFF_MILLIS, | ||
| ) : MessageFooterVisibility() | ||
|
|
||
| /** | ||
| * The message footer will be visible for every message. | ||
| */ | ||
| public object Always : MessageFooterVisibility() { | ||
| override fun toString(): String = "Always" | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The default time difference after which the footer is shown. | ||
| */ | ||
| private const val DEFAULT_FOOTER_TIME_DIFF_MILLIS: Long = 60 * 1000L | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Edited" should be shown even when the rest of the footer is not shown