-
Notifications
You must be signed in to change notification settings - Fork 232
Reply action: harmonize condition #1271
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
Changes from 3 commits
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Reply action: harmonize conditions in bottom sheet and swipe to reply. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ class ActionListPresenter @Inject constructor( | |
is ActionListEvents.ComputeForMessage -> localCoroutineScope.computeForMessage( | ||
timelineItem = event.event, | ||
userCanRedact = event.canRedact, | ||
userCanSendMessage = event.canSendMessage, | ||
target = target, | ||
) | ||
} | ||
|
@@ -77,6 +78,7 @@ class ActionListPresenter @Inject constructor( | |
private fun CoroutineScope.computeForMessage( | ||
timelineItem: TimelineItem.Event, | ||
userCanRedact: Boolean, | ||
userCanSendMessage: Boolean, | ||
target: MutableState<ActionListState.Target> | ||
) = launch { | ||
target.value = ActionListState.Target.Loading(timelineItem) | ||
|
@@ -101,7 +103,8 @@ class ActionListPresenter @Inject constructor( | |
buildList { | ||
val isMineOrCanRedact = timelineItem.isMine || userCanRedact | ||
|
||
// TODO Poll: Reply to poll | ||
// TODO Poll: Reply to poll. Ensure to update `fun TimelineItemEventContent.canBeReplied()` | ||
// when touching this | ||
// if (timelineItem.isRemote) { | ||
// // Can only reply or forward messages already uploaded to the server | ||
// add(TimelineItemAction.Reply) | ||
|
@@ -126,7 +129,9 @@ class ActionListPresenter @Inject constructor( | |
else -> buildList<TimelineItemAction> { | ||
if (timelineItem.isRemote) { | ||
// Can only reply or forward messages already uploaded to the server | ||
add(TimelineItemAction.Reply) | ||
if (userCanSendMessage) { | ||
add(TimelineItemAction.Reply) | ||
} | ||
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. This is fix 1 |
||
add(TimelineItemAction.Forward) | ||
} | ||
if (timelineItem.isMine && timelineItem.isTextMessage) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ import io.element.android.features.messages.impl.timeline.model.TimelineItem | |
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemEventContent | ||
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemEventContentProvider | ||
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemStateContent | ||
import io.element.android.features.messages.impl.timeline.model.event.canBeReplied | ||
import io.element.android.libraries.designsystem.preview.DayNightPreviews | ||
import io.element.android.libraries.designsystem.preview.ElementPreview | ||
import io.element.android.libraries.designsystem.theme.components.FloatingActionButton | ||
|
@@ -119,7 +120,7 @@ fun TimelineView( | |
TimelineItemRow( | ||
timelineItem = timelineItem, | ||
highlightedItem = state.highlightedEventId?.value, | ||
canReply = state.canReply, | ||
userHasPermissionToSendMessage = state.userHasPermissionToSendMessage, | ||
onClick = onMessageClicked, | ||
onLongClick = onMessageLongClicked, | ||
onUserDataClick = onUserDataClicked, | ||
|
@@ -156,7 +157,7 @@ fun TimelineView( | |
fun TimelineItemRow( | ||
timelineItem: TimelineItem, | ||
highlightedItem: String?, | ||
canReply: Boolean, | ||
userHasPermissionToSendMessage: Boolean, | ||
onUserDataClick: (UserId) -> Unit, | ||
onClick: (TimelineItem.Event) -> Unit, | ||
onLongClick: (TimelineItem.Event) -> Unit, | ||
|
@@ -189,7 +190,7 @@ fun TimelineItemRow( | |
TimelineItemEventRow( | ||
event = timelineItem, | ||
isHighlighted = highlightedItem == timelineItem.identifier(), | ||
canReply = canReply, | ||
canReply = userHasPermissionToSendMessage && timelineItem.content.canBeReplied(), | ||
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. This is fix 2 |
||
onClick = { onClick(timelineItem) }, | ||
onLongClick = { onLongClick(timelineItem) }, | ||
onUserDataClick = onUserDataClick, | ||
|
@@ -228,7 +229,7 @@ fun TimelineItemRow( | |
TimelineItemRow( | ||
timelineItem = subGroupEvent, | ||
highlightedItem = highlightedItem, | ||
canReply = false, | ||
userHasPermissionToSendMessage = false, | ||
onClick = onClick, | ||
onLongClick = onLongClick, | ||
inReplyToClick = inReplyToClick, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,18 @@ fun TimelineItemEventContent.canBeCopied(): Boolean = | |
else -> false | ||
} | ||
|
||
/** | ||
* Determine if the event content can be replied to. | ||
* Note: it should match the logic in [io.element.android.features.messages.impl.actionlist.ActionListPresenter]. | ||
*/ | ||
fun TimelineItemEventContent.canBeReplied(): Boolean = | ||
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. Nit: it should probably be 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. |
||
when (this) { | ||
is TimelineItemRedactedContent, | ||
is TimelineItemStateContent, | ||
is TimelineItemPollContent -> false | ||
else -> true | ||
} | ||
|
||
/** | ||
* Return true if user can react (i.e. send a reaction) on the event content. | ||
*/ | ||
|
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.
👌