mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-17 19:58:57 +03:00
RoomDetail: fix enter/exit mode again after merge
This commit is contained in:
parent
ec71b53c1e
commit
d2acabddd9
3 changed files with 16 additions and 14 deletions
|
@ -42,10 +42,10 @@ sealed class RoomDetailAction : VectorViewModelAction {
|
|||
object AcceptInvite : RoomDetailAction()
|
||||
object RejectInvite : RoomDetailAction()
|
||||
|
||||
data class EnterEditMode(val eventId: String, val draft: String) : RoomDetailAction()
|
||||
data class EnterQuoteMode(val eventId: String, val draft: String) : RoomDetailAction()
|
||||
data class EnterReplyMode(val eventId: String, val draft: String) : RoomDetailAction()
|
||||
data class ExitSpecialMode(val draft: String) : RoomDetailAction()
|
||||
data class EnterEditMode(val eventId: String, val text: String) : RoomDetailAction()
|
||||
data class EnterQuoteMode(val eventId: String, val text: String) : RoomDetailAction()
|
||||
data class EnterReplyMode(val eventId: String, val text: String) : RoomDetailAction()
|
||||
data class ExitSpecialMode(val text: String) : RoomDetailAction()
|
||||
|
||||
data class ResendMessage(val eventId: String) : RoomDetailAction()
|
||||
data class RemoveFailedEcho(val eventId: String) : RoomDetailAction()
|
||||
|
|
|
@ -521,9 +521,10 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
|
||||
private fun handleEditAction(action: RoomDetailAction.EnterEditMode) {
|
||||
saveCurrentDraft(action.draft)
|
||||
saveCurrentDraft(action.text)
|
||||
|
||||
room.getTimeLineEvent(action.eventId)?.let { timelineEvent ->
|
||||
setState { copy(sendMode = SendMode.EDIT(timelineEvent, action.text)) }
|
||||
timelineEvent.root.eventId?.let {
|
||||
room.saveDraft(UserDraft.EDIT(it, timelineEvent.getTextEditableContent() ?: ""))
|
||||
}
|
||||
|
@ -531,16 +532,17 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
|
||||
private fun handleQuoteAction(action: RoomDetailAction.EnterQuoteMode) {
|
||||
saveCurrentDraft(action.draft)
|
||||
saveCurrentDraft(action.text)
|
||||
|
||||
room.getTimeLineEvent(action.eventId)?.let { timelineEvent ->
|
||||
setState { copy(sendMode = SendMode.QUOTE(timelineEvent, action.text)) }
|
||||
withState { state ->
|
||||
// Save a new draft and keep the previously entered text, if it was not an edit
|
||||
timelineEvent.root.eventId?.let {
|
||||
if (state.sendMode is SendMode.EDIT) {
|
||||
room.saveDraft(UserDraft.QUOTE(it, ""))
|
||||
} else {
|
||||
room.saveDraft(UserDraft.QUOTE(it, action.draft))
|
||||
room.saveDraft(UserDraft.QUOTE(it, action.text))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -548,16 +550,17 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
|
||||
private fun handleReplyAction(action: RoomDetailAction.EnterReplyMode) {
|
||||
saveCurrentDraft(action.draft)
|
||||
saveCurrentDraft(action.text)
|
||||
|
||||
room.getTimeLineEvent(action.eventId)?.let { timelineEvent ->
|
||||
setState { copy(sendMode = SendMode.REPLY(timelineEvent, action.text)) }
|
||||
withState { state ->
|
||||
// Save a new draft and keep the previously entered text, if it was not an edit
|
||||
timelineEvent.root.eventId?.let {
|
||||
if (state.sendMode is SendMode.EDIT) {
|
||||
room.saveDraft(UserDraft.REPLY(it, ""))
|
||||
} else {
|
||||
room.saveDraft(UserDraft.REPLY(it, action.draft))
|
||||
room.saveDraft(UserDraft.REPLY(it, action.text))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -579,13 +582,14 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
|
||||
private fun handleExitSpecialMode(action: RoomDetailAction.ExitSpecialMode) {
|
||||
setState { copy(sendMode = SendMode.REGULAR(action.text)) }
|
||||
withState { state ->
|
||||
// For edit, just delete the current draft
|
||||
if (state.sendMode is SendMode.EDIT) {
|
||||
room.deleteDraft()
|
||||
} else {
|
||||
// Save a new draft and keep the previously entered text
|
||||
room.saveDraft(UserDraft.REGULAR(action.draft))
|
||||
room.saveDraft(UserDraft.REGULAR(action.text))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,10 +90,8 @@
|
|||
|
||||
<ImageButton
|
||||
android:id="@+id/composer_related_message_close"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:src="@drawable/ic_close_round"
|
||||
android:tint="@color/riotx_notice"
|
||||
|
|
Loading…
Add table
Reference in a new issue