diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageMenuViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageMenuViewModel.kt index 15e0883114..fcf0017321 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageMenuViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageMenuViewModel.kt @@ -99,39 +99,32 @@ class MessageMenuViewModel @AssistedInject constructor(@Assisted initialState: M private fun observeEvent() { RxRoom(room) .liveTimelineEvent(eventId) - ?.map { + .map { actionsForEvent(it) } - ?.execute { + .execute { copy(actions = it) } } private fun actionsForEvent(event: TimelineEvent): List { - val messageContent: MessageContent? = event.annotations?.editSummary?.aggregatedContent.toModel() ?: event.root.getClearContent().toModel() val type = messageContent?.type - return if (event.root.sendState.hasFailed()) { - arrayListOf().apply { + return arrayListOf().apply { + if (event.root.sendState.hasFailed()) { if (canRetry(event)) { - this.add(SimpleAction(ACTION_RESEND, R.string.global_retry, R.drawable.ic_refresh_cw, eventId)) + add(SimpleAction(ACTION_RESEND, R.string.global_retry, R.drawable.ic_refresh_cw, eventId)) } - this.add(SimpleAction(ACTION_REMOVE, R.string.remove, R.drawable.ic_trash, eventId)) - } - } else if (event.root.sendState.isSending()) { - //TODO is uploading attachment? - arrayListOf().apply { + add(SimpleAction(ACTION_REMOVE, R.string.remove, R.drawable.ic_trash, eventId)) + } else if (event.root.sendState.isSending()) { + //TODO is uploading attachment? if (canCancel(event)) { - this.add(SimpleAction(ACTION_CANCEL, R.string.cancel, R.drawable.ic_close_round, eventId)) + add(SimpleAction(ACTION_CANCEL, R.string.cancel, R.drawable.ic_close_round, eventId)) } - } - } else { - arrayListOf().apply { - + } else { if (!event.root.isRedacted()) { - if (canReply(event, messageContent)) { add(SimpleAction(ACTION_REPLY, R.string.reply, R.drawable.ic_reply, eventId)) }