Quick Work around to remove stuck messages

This commit is contained in:
Valere 2021-03-16 12:16:11 +01:00
parent e8d4fab305
commit 5b94540f76
6 changed files with 40 additions and 18 deletions

View File

@ -8,7 +8,7 @@ Improvements 🙌:
- -
Bugfix 🐛: Bugfix 🐛:
- - Add option to cancel stuck messages at bottom of timeline see #516
Translations 🗣: Translations 🗣:
- -

View File

@ -58,7 +58,7 @@ sealed class RoomDetailAction : VectorViewModelAction {
data class ResendMessage(val eventId: String) : RoomDetailAction() data class ResendMessage(val eventId: String) : RoomDetailAction()
data class RemoveFailedEcho(val eventId: String) : RoomDetailAction() data class RemoveFailedEcho(val eventId: String) : RoomDetailAction()
data class CancelSend(val eventId: String) : RoomDetailAction() data class CancelSend(val eventId: String, val force: Boolean) : RoomDetailAction()
data class ReplyToOptions(val eventId: String, val optionIndex: Int, val optionValue: String) : RoomDetailAction() data class ReplyToOptions(val eventId: String, val optionIndex: Int, val optionValue: String) : RoomDetailAction()

View File

@ -1570,15 +1570,19 @@ class RoomDetailFragment @Inject constructor(
} }
private fun handleCancelSend(action: EventSharedAction.Cancel) { private fun handleCancelSend(action: EventSharedAction.Cancel) {
if (action.force) {
roomDetailViewModel.handle(RoomDetailAction.CancelSend(action.eventId, true))
} else {
AlertDialog.Builder(requireContext()) AlertDialog.Builder(requireContext())
.setTitle(R.string.dialog_title_confirmation) .setTitle(R.string.dialog_title_confirmation)
.setMessage(getString(R.string.event_status_cancel_sending_dialog_message)) .setMessage(getString(R.string.event_status_cancel_sending_dialog_message))
.setNegativeButton(R.string.no, null) .setNegativeButton(R.string.no, null)
.setPositiveButton(R.string.yes) { _, _ -> .setPositiveButton(R.string.yes) { _, _ ->
roomDetailViewModel.handle(RoomDetailAction.CancelSend(action.eventId)) roomDetailViewModel.handle(RoomDetailAction.CancelSend(action.eventId, false))
} }
.show() .show()
} }
}
override fun onAvatarClicked(informationData: MessageInformationData) { override fun onAvatarClicked(informationData: MessageInformationData) {
// roomDetailViewModel.handle(RoomDetailAction.RequestVerification(informationData.userId)) // roomDetailViewModel.handle(RoomDetailAction.RequestVerification(informationData.userId))

View File

@ -1208,6 +1208,10 @@ class RoomDetailViewModel @AssistedInject constructor(
} }
private fun handleCancel(action: RoomDetailAction.CancelSend) { private fun handleCancel(action: RoomDetailAction.CancelSend) {
if (action.force) {
room.cancelSend(action.eventId)
return
}
val targetEventId = action.eventId val targetEventId = action.eventId
room.getTimeLineEvent(targetEventId)?.let { room.getTimeLineEvent(targetEventId)?.let {
// State must be in one of the sending states // State must be in one of the sending states

View File

@ -63,7 +63,7 @@ sealed class EventSharedAction(@StringRes val titleRes: Int,
data class Redact(val eventId: String, val askForReason: Boolean) : data class Redact(val eventId: String, val askForReason: Boolean) :
EventSharedAction(R.string.message_action_item_redact, R.drawable.ic_delete, true) EventSharedAction(R.string.message_action_item_redact, R.drawable.ic_delete, true)
data class Cancel(val eventId: String) : data class Cancel(val eventId: String, val force: Boolean) :
EventSharedAction(R.string.cancel, R.drawable.ic_close_round) EventSharedAction(R.string.cancel, R.drawable.ic_close_round)
data class ViewSource(val content: String) : data class ViewSource(val content: String) :

View File

@ -250,6 +250,9 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
timelineEvent.root.sendState == SendState.SYNCED -> { timelineEvent.root.sendState == SendState.SYNCED -> {
addActionsForSyncedState(timelineEvent, actionPermissions, messageContent, msgType) addActionsForSyncedState(timelineEvent, actionPermissions, messageContent, msgType)
} }
timelineEvent.root.sendState == SendState.SENT -> {
addActionsForSentNotSyncedState(timelineEvent, actionPermissions, messageContent, msgType)
}
} }
} }
} }
@ -287,7 +290,24 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
private fun ArrayList<EventSharedAction>.addActionsForSendingState(timelineEvent: TimelineEvent) { private fun ArrayList<EventSharedAction>.addActionsForSendingState(timelineEvent: TimelineEvent) {
// TODO is uploading attachment? // TODO is uploading attachment?
if (canCancel(timelineEvent)) { if (canCancel(timelineEvent)) {
add(EventSharedAction.Cancel(timelineEvent.eventId)) add(EventSharedAction.Cancel(timelineEvent.eventId, false))
}
}
private fun ArrayList<EventSharedAction>.addActionsForSentNotSyncedState(timelineEvent: TimelineEvent,
actionPermissions: ActionPermissions,
messageContent: MessageContent?,
msgType: String?) {
if (timelineEvent.root.sendState == SendState.SENT) {
// If sent but not synced (synapse stuck at bottom bug)
// Still offer action to cancel (will only remove local echo)
timelineEvent.root.eventId?.let {
add(EventSharedAction.Cancel(it, true))
}
// TODO Can be redacted
// TODO sent by me or sufficient power level
} }
} }
@ -337,12 +357,6 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
if (canSave(msgType) && messageContent is MessageWithAttachmentContent) { if (canSave(msgType) && messageContent is MessageWithAttachmentContent) {
add(EventSharedAction.Save(timelineEvent.eventId, messageContent)) add(EventSharedAction.Save(timelineEvent.eventId, messageContent))
} }
if (timelineEvent.root.sendState == SendState.SENT) {
// TODO Can be redacted
// TODO sent by me or sufficient power level
}
} }
if (vectorPreferences.developerMode()) { if (vectorPreferences.developerMode()) {