Move class to dedicated file
This commit is contained in:
parent
70bce9e7dd
commit
a6fcc7dca6
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.riotx.features.home.room.detail.timeline.action
|
||||||
|
|
||||||
|
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||||
|
|
||||||
|
sealed class MessageActionsActions : VectorViewModelAction {
|
||||||
|
object ToggleReportMenu : MessageActionsActions()
|
||||||
|
}
|
@ -72,7 +72,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
|
|||||||
override fun didSelectMenuAction(eventAction: EventSharedAction) {
|
override fun didSelectMenuAction(eventAction: EventSharedAction) {
|
||||||
if (eventAction is EventSharedAction.ReportContent) {
|
if (eventAction is EventSharedAction.ReportContent) {
|
||||||
// Toggle report menu
|
// Toggle report menu
|
||||||
viewModel.handle(MessageActionActions.ToggleReportMenu)
|
viewModel.handle(MessageActionsActions.ToggleReportMenu)
|
||||||
} else {
|
} else {
|
||||||
messageActionsStore.post(eventAction)
|
messageActionsStore.post(eventAction)
|
||||||
dismiss()
|
dismiss()
|
||||||
|
@ -37,7 +37,6 @@ import im.vector.matrix.rx.unwrap
|
|||||||
import im.vector.riotx.R
|
import im.vector.riotx.R
|
||||||
import im.vector.riotx.core.extensions.canReact
|
import im.vector.riotx.core.extensions.canReact
|
||||||
import im.vector.riotx.core.platform.VectorViewModel
|
import im.vector.riotx.core.platform.VectorViewModel
|
||||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
|
||||||
import im.vector.riotx.core.resources.StringProvider
|
import im.vector.riotx.core.resources.StringProvider
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.format.NoticeEventFormatter
|
import im.vector.riotx.features.home.room.detail.timeline.format.NoticeEventFormatter
|
||||||
import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData
|
import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData
|
||||||
@ -77,10 +76,6 @@ data class MessageActionState(
|
|||||||
fun canReact() = timelineEvent()?.canReact() == true
|
fun canReact() = timelineEvent()?.canReact() == true
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class MessageActionActions : VectorViewModelAction {
|
|
||||||
object ToggleReportMenu : MessageActionActions()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information related to an event and used to display preview in contextual bottom sheet.
|
* Information related to an event and used to display preview in contextual bottom sheet.
|
||||||
*/
|
*/
|
||||||
@ -90,7 +85,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
|||||||
private val session: Session,
|
private val session: Session,
|
||||||
private val noticeEventFormatter: NoticeEventFormatter,
|
private val noticeEventFormatter: NoticeEventFormatter,
|
||||||
private val stringProvider: StringProvider
|
private val stringProvider: StringProvider
|
||||||
) : VectorViewModel<MessageActionState, MessageActionActions>(initialState) {
|
) : VectorViewModel<MessageActionState, MessageActionsActions>(initialState) {
|
||||||
|
|
||||||
private val eventId = initialState.eventId
|
private val eventId = initialState.eventId
|
||||||
private val informationData = initialState.informationData
|
private val informationData = initialState.informationData
|
||||||
@ -117,9 +112,9 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
|||||||
observeEventAction()
|
observeEventAction()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handle(action: MessageActionActions) {
|
override fun handle(action: MessageActionsActions) {
|
||||||
when (action) {
|
when (action) {
|
||||||
MessageActionActions.ToggleReportMenu -> toggleReportMenu()
|
MessageActionsActions.ToggleReportMenu -> toggleReportMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user