Quick Work around to remove stuck messages
This commit is contained in:
parent
e8d4fab305
commit
5b94540f76
|
@ -8,7 +8,7 @@ Improvements 🙌:
|
||||||
-
|
-
|
||||||
|
|
||||||
Bugfix 🐛:
|
Bugfix 🐛:
|
||||||
-
|
- Add option to cancel stuck messages at bottom of timeline see #516
|
||||||
|
|
||||||
Translations 🗣:
|
Translations 🗣:
|
||||||
-
|
-
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
|
@ -1570,14 +1570,18 @@ class RoomDetailFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleCancelSend(action: EventSharedAction.Cancel) {
|
private fun handleCancelSend(action: EventSharedAction.Cancel) {
|
||||||
AlertDialog.Builder(requireContext())
|
if (action.force) {
|
||||||
.setTitle(R.string.dialog_title_confirmation)
|
roomDetailViewModel.handle(RoomDetailAction.CancelSend(action.eventId, true))
|
||||||
.setMessage(getString(R.string.event_status_cancel_sending_dialog_message))
|
} else {
|
||||||
.setNegativeButton(R.string.no, null)
|
AlertDialog.Builder(requireContext())
|
||||||
.setPositiveButton(R.string.yes) { _, _ ->
|
.setTitle(R.string.dialog_title_confirmation)
|
||||||
roomDetailViewModel.handle(RoomDetailAction.CancelSend(action.eventId))
|
.setMessage(getString(R.string.event_status_cancel_sending_dialog_message))
|
||||||
}
|
.setNegativeButton(R.string.no, null)
|
||||||
.show()
|
.setPositiveButton(R.string.yes) { _, _ ->
|
||||||
|
roomDetailViewModel.handle(RoomDetailAction.CancelSend(action.eventId, false))
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAvatarClicked(informationData: MessageInformationData) {
|
override fun onAvatarClicked(informationData: MessageInformationData) {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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) :
|
||||||
|
|
|
@ -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()) {
|
||||||
|
|
Loading…
Reference in New Issue