Move class to dedicated file

This commit is contained in:
Benoit Marty 2019-11-08 15:07:01 +01:00
parent 70bce9e7dd
commit a6fcc7dca6
3 changed files with 27 additions and 9 deletions

View File

@ -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()
}

View File

@ -72,7 +72,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
override fun didSelectMenuAction(eventAction: EventSharedAction) {
if (eventAction is EventSharedAction.ReportContent) {
// Toggle report menu
viewModel.handle(MessageActionActions.ToggleReportMenu)
viewModel.handle(MessageActionsActions.ToggleReportMenu)
} else {
messageActionsStore.post(eventAction)
dismiss()

View File

@ -37,7 +37,6 @@ import im.vector.matrix.rx.unwrap
import im.vector.riotx.R
import im.vector.riotx.core.extensions.canReact
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.features.home.room.detail.timeline.format.NoticeEventFormatter
import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData
@ -77,10 +76,6 @@ data class MessageActionState(
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.
*/
@ -90,7 +85,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
private val session: Session,
private val noticeEventFormatter: NoticeEventFormatter,
private val stringProvider: StringProvider
) : VectorViewModel<MessageActionState, MessageActionActions>(initialState) {
) : VectorViewModel<MessageActionState, MessageActionsActions>(initialState) {
private val eventId = initialState.eventId
private val informationData = initialState.informationData
@ -117,9 +112,9 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
observeEventAction()
}
override fun handle(action: MessageActionActions) {
override fun handle(action: MessageActionsActions) {
when (action) {
MessageActionActions.ToggleReportMenu -> toggleReportMenu()
MessageActionsActions.ToggleReportMenu -> toggleReportMenu()
}
}