Rename class
This commit is contained in:
parent
f17564d743
commit
12376368c7
|
@ -23,10 +23,6 @@ import im.vector.riotx.core.utils.LiveEvent
|
|||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
|
||||
interface VectorViewModelAction
|
||||
|
||||
object EmptyAction : VectorViewModelAction
|
||||
|
||||
abstract class VectorViewModel<S : MvRxState, A : VectorViewModelAction>(initialState: S)
|
||||
: BaseMvRxViewModel<S>(initialState, false) {
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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.core.platform
|
||||
|
||||
interface VectorViewModelAction
|
||||
|
||||
/**
|
||||
* To use when no action is associated to the ViewModel
|
||||
*/
|
||||
object EmptyAction : VectorViewModelAction
|
|
@ -18,8 +18,8 @@ package im.vector.riotx.features.crypto.keysbackup.settings
|
|||
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class KeyBackupSettingsActions : VectorViewModelAction {
|
||||
object Init : KeyBackupSettingsActions()
|
||||
object GetKeyBackupTrust : KeyBackupSettingsActions()
|
||||
object DeleteKeyBackup : KeyBackupSettingsActions()
|
||||
sealed class KeyBackupSettingsAction : VectorViewModelAction {
|
||||
object Init : KeyBackupSettingsAction()
|
||||
object GetKeyBackupTrust : KeyBackupSettingsAction()
|
||||
object DeleteKeyBackup : KeyBackupSettingsAction()
|
||||
}
|
|
@ -51,7 +51,7 @@ class KeysBackupManageActivity : SimpleFragmentActivity() {
|
|||
super.initUiAndData()
|
||||
if (supportFragmentManager.fragments.isEmpty()) {
|
||||
replaceFragment(R.id.container, KeysBackupSettingsFragment::class.java)
|
||||
viewModel.handle(KeyBackupSettingsActions.Init)
|
||||
viewModel.handle(KeyBackupSettingsAction.Init)
|
||||
}
|
||||
|
||||
// Observe the deletion of keys backup
|
||||
|
|
|
@ -66,7 +66,7 @@ class KeysBackupSettingsFragment @Inject constructor(private val keysBackupSetti
|
|||
.setMessage(R.string.keys_backup_settings_delete_confirm_message)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.keys_backup_settings_delete_confirm_title) { _, _ ->
|
||||
viewModel.handle(KeyBackupSettingsActions.DeleteKeyBackup)
|
||||
viewModel.handle(KeyBackupSettingsAction.DeleteKeyBackup)
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setCancelable(true)
|
||||
|
@ -75,10 +75,10 @@ class KeysBackupSettingsFragment @Inject constructor(private val keysBackupSetti
|
|||
}
|
||||
|
||||
override fun loadTrustData() {
|
||||
viewModel.handle(KeyBackupSettingsActions.GetKeyBackupTrust)
|
||||
viewModel.handle(KeyBackupSettingsAction.GetKeyBackupTrust)
|
||||
}
|
||||
|
||||
override fun loadKeysBackupState() {
|
||||
viewModel.handle(KeyBackupSettingsActions.Init)
|
||||
viewModel.handle(KeyBackupSettingsAction.Init)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import im.vector.riotx.core.platform.VectorViewModel
|
|||
|
||||
class KeysBackupSettingsViewModel @AssistedInject constructor(@Assisted initialState: KeysBackupSettingViewState,
|
||||
session: Session
|
||||
) : VectorViewModel<KeysBackupSettingViewState, KeyBackupSettingsActions>(initialState),
|
||||
) : VectorViewModel<KeysBackupSettingViewState, KeyBackupSettingsAction>(initialState),
|
||||
KeysBackupStateListener {
|
||||
|
||||
@AssistedInject.Factory
|
||||
|
@ -58,11 +58,11 @@ class KeysBackupSettingsViewModel @AssistedInject constructor(@Assisted initialS
|
|||
getKeysBackupTrust()
|
||||
}
|
||||
|
||||
override fun handle(action: KeyBackupSettingsActions) {
|
||||
override fun handle(action: KeyBackupSettingsAction) {
|
||||
when (action) {
|
||||
KeyBackupSettingsActions.Init -> init()
|
||||
KeyBackupSettingsActions.GetKeyBackupTrust -> getKeysBackupTrust()
|
||||
KeyBackupSettingsActions.DeleteKeyBackup -> deleteCurrentBackup()
|
||||
KeyBackupSettingsAction.Init -> init()
|
||||
KeyBackupSettingsAction.GetKeyBackupTrust -> getKeysBackupTrust()
|
||||
KeyBackupSettingsAction.DeleteKeyBackup -> deleteCurrentBackup()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ package im.vector.riotx.features.home.createdirect
|
|||
import im.vector.matrix.android.api.session.user.model.User
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class CreateDirectRoomActions : VectorViewModelAction {
|
||||
object CreateRoomAndInviteSelectedUsers : CreateDirectRoomActions()
|
||||
data class FilterKnownUsers(val value: String) : CreateDirectRoomActions()
|
||||
data class SearchDirectoryUsers(val value: String) : CreateDirectRoomActions()
|
||||
object ClearFilterKnownUsers : CreateDirectRoomActions()
|
||||
data class SelectUser(val user: User) : CreateDirectRoomActions()
|
||||
data class RemoveSelectedUser(val user: User) : CreateDirectRoomActions()
|
||||
sealed class CreateDirectRoomAction : VectorViewModelAction {
|
||||
object CreateRoomAndInviteSelectedUsers : CreateDirectRoomAction()
|
||||
data class FilterKnownUsers(val value: String) : CreateDirectRoomAction()
|
||||
data class SearchDirectoryUsers(val value: String) : CreateDirectRoomAction()
|
||||
object ClearFilterKnownUsers : CreateDirectRoomAction()
|
||||
data class SelectUser(val user: User) : CreateDirectRoomAction()
|
||||
data class RemoveSelectedUser(val user: User) : CreateDirectRoomAction()
|
||||
}
|
|
@ -60,7 +60,7 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
|
|||
createDirectRoomSearchById
|
||||
.textChanges()
|
||||
.subscribe {
|
||||
viewModel.handle(CreateDirectRoomActions.SearchDirectoryUsers(it.toString()))
|
||||
viewModel.handle(CreateDirectRoomAction.SearchDirectoryUsers(it.toString()))
|
||||
}
|
||||
.disposeOnDestroy()
|
||||
createDirectRoomSearchById.requestFocus()
|
||||
|
@ -80,12 +80,12 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor(
|
|||
|
||||
override fun onItemClick(user: User) {
|
||||
view?.hideKeyboard()
|
||||
viewModel.handle(CreateDirectRoomActions.SelectUser(user))
|
||||
viewModel.handle(CreateDirectRoomAction.SelectUser(user))
|
||||
actionViewModel.post(CreateDirectRoomSharedAction.GoBack)
|
||||
}
|
||||
|
||||
override fun retryDirectoryUsersRequest() {
|
||||
val currentSearch = createDirectRoomSearchById.text.toString()
|
||||
viewModel.handle(CreateDirectRoomActions.SearchDirectoryUsers(currentSearch))
|
||||
viewModel.handle(CreateDirectRoomAction.SearchDirectoryUsers(currentSearch))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
|
|||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_create_direct_room -> {
|
||||
viewModel.handle(CreateDirectRoomActions.CreateRoomAndInviteSelectedUsers)
|
||||
viewModel.handle(CreateDirectRoomAction.CreateRoomAndInviteSelectedUsers)
|
||||
true
|
||||
}
|
||||
else ->
|
||||
|
@ -108,9 +108,9 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
|
|||
.subscribe { text ->
|
||||
val filterValue = text.trim()
|
||||
val action = if (filterValue.isBlank()) {
|
||||
CreateDirectRoomActions.ClearFilterKnownUsers
|
||||
CreateDirectRoomAction.ClearFilterKnownUsers
|
||||
} else {
|
||||
CreateDirectRoomActions.FilterKnownUsers(filterValue.toString())
|
||||
CreateDirectRoomAction.FilterKnownUsers(filterValue.toString())
|
||||
}
|
||||
viewModel.handle(action)
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
|
|||
chip.isCloseIconVisible = true
|
||||
chipGroup.addView(chip)
|
||||
chip.setOnCloseIconClickListener {
|
||||
viewModel.handle(CreateDirectRoomActions.RemoveSelectedUser(user))
|
||||
viewModel.handle(CreateDirectRoomAction.RemoveSelectedUser(user))
|
||||
}
|
||||
chipGroupScrollView.post {
|
||||
chipGroupScrollView.fullScroll(ScrollView.FOCUS_DOWN)
|
||||
|
@ -166,6 +166,6 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
|
|||
|
||||
override fun onItemClick(user: User) {
|
||||
view?.hideKeyboard()
|
||||
viewModel.handle(CreateDirectRoomActions.SelectUser(user))
|
||||
viewModel.handle(CreateDirectRoomAction.SelectUser(user))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ data class SelectUserAction(
|
|||
class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted
|
||||
initialState: CreateDirectRoomViewState,
|
||||
private val session: Session)
|
||||
: VectorViewModel<CreateDirectRoomViewState, CreateDirectRoomActions>(initialState) {
|
||||
: VectorViewModel<CreateDirectRoomViewState, CreateDirectRoomAction>(initialState) {
|
||||
|
||||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
|
@ -79,14 +79,14 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted
|
|||
observeDirectoryUsers()
|
||||
}
|
||||
|
||||
override fun handle(action: CreateDirectRoomActions) {
|
||||
override fun handle(action: CreateDirectRoomAction) {
|
||||
when (action) {
|
||||
is CreateDirectRoomActions.CreateRoomAndInviteSelectedUsers -> createRoomAndInviteSelectedUsers()
|
||||
is CreateDirectRoomActions.FilterKnownUsers -> knownUsersFilter.accept(Option.just(action.value))
|
||||
is CreateDirectRoomActions.ClearFilterKnownUsers -> knownUsersFilter.accept(Option.empty())
|
||||
is CreateDirectRoomActions.SearchDirectoryUsers -> directoryUsersSearch.accept(action.value)
|
||||
is CreateDirectRoomActions.SelectUser -> handleSelectUser(action)
|
||||
is CreateDirectRoomActions.RemoveSelectedUser -> handleRemoveSelectedUser(action)
|
||||
is CreateDirectRoomAction.CreateRoomAndInviteSelectedUsers -> createRoomAndInviteSelectedUsers()
|
||||
is CreateDirectRoomAction.FilterKnownUsers -> knownUsersFilter.accept(Option.just(action.value))
|
||||
is CreateDirectRoomAction.ClearFilterKnownUsers -> knownUsersFilter.accept(Option.empty())
|
||||
is CreateDirectRoomAction.SearchDirectoryUsers -> directoryUsersSearch.accept(action.value)
|
||||
is CreateDirectRoomAction.SelectUser -> handleSelectUser(action)
|
||||
is CreateDirectRoomAction.RemoveSelectedUser -> handleRemoveSelectedUser(action)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,14 +105,14 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleRemoveSelectedUser(action: CreateDirectRoomActions.RemoveSelectedUser) = withState { state ->
|
||||
private fun handleRemoveSelectedUser(action: CreateDirectRoomAction.RemoveSelectedUser) = withState { state ->
|
||||
val index = state.selectedUsers.indexOfFirst { it.userId == action.user.userId }
|
||||
val selectedUsers = state.selectedUsers.minus(action.user)
|
||||
setState { copy(selectedUsers = selectedUsers) }
|
||||
_selectUserEvent.postLiveEvent(SelectUserAction(action.user, false, index))
|
||||
}
|
||||
|
||||
private fun handleSelectUser(action: CreateDirectRoomActions.SelectUser) = withState { state ->
|
||||
private fun handleSelectUser(action: CreateDirectRoomAction.SelectUser) = withState { state ->
|
||||
// Reset the filter asap
|
||||
directoryUsersSearch.accept("")
|
||||
val isAddOperation: Boolean
|
||||
|
|
|
@ -19,6 +19,6 @@ package im.vector.riotx.features.home.group
|
|||
import im.vector.matrix.android.api.session.group.model.GroupSummary
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class GroupListActions : VectorViewModelAction {
|
||||
data class SelectGroup(val groupSummary: GroupSummary) : GroupListActions()
|
||||
sealed class GroupListAction : VectorViewModelAction {
|
||||
data class SelectGroup(val groupSummary: GroupSummary) : GroupListAction()
|
||||
}
|
|
@ -62,6 +62,6 @@ class GroupListFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onGroupSelected(groupSummary: GroupSummary) {
|
||||
viewModel.handle(GroupListActions.SelectGroup(groupSummary))
|
||||
viewModel.handle(GroupListAction.SelectGroup(groupSummary))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class GroupListViewModel @AssistedInject constructor(@Assisted initialState: Gro
|
|||
private val selectedGroupStore: SelectedGroupDataSource,
|
||||
private val session: Session,
|
||||
private val stringProvider: StringProvider
|
||||
) : VectorViewModel<GroupListViewState, GroupListActions>(initialState) {
|
||||
) : VectorViewModel<GroupListViewState, GroupListAction>(initialState) {
|
||||
|
||||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
|
@ -81,15 +81,15 @@ class GroupListViewModel @AssistedInject constructor(@Assisted initialState: Gro
|
|||
}
|
||||
}
|
||||
|
||||
override fun handle(action: GroupListActions) {
|
||||
override fun handle(action: GroupListAction) {
|
||||
when (action) {
|
||||
is GroupListActions.SelectGroup -> handleSelectGroup(action)
|
||||
is GroupListAction.SelectGroup -> handleSelectGroup(action)
|
||||
}
|
||||
}
|
||||
|
||||
// PRIVATE METHODS *****************************************************************************
|
||||
|
||||
private fun handleSelectGroup(action: GroupListActions.SelectGroup) = withState { state ->
|
||||
private fun handleSelectGroup(action: GroupListAction.SelectGroup) = withState { state ->
|
||||
if (state.selectedGroup?.groupId != action.groupSummary.groupId) {
|
||||
setState { copy(selectedGroup = action.groupSummary) }
|
||||
}
|
||||
|
|
|
@ -23,42 +23,42 @@ import im.vector.matrix.android.api.session.room.timeline.Timeline
|
|||
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class RoomDetailActions : VectorViewModelAction {
|
||||
data class SaveDraft(val draft: String) : RoomDetailActions()
|
||||
data class SendMessage(val text: String, val autoMarkdown: Boolean) : RoomDetailActions()
|
||||
data class SendMedia(val attachments: List<ContentAttachmentData>) : RoomDetailActions()
|
||||
data class TimelineEventTurnsVisible(val event: TimelineEvent) : RoomDetailActions()
|
||||
data class TimelineEventTurnsInvisible(val event: TimelineEvent) : RoomDetailActions()
|
||||
data class LoadMoreTimelineEvents(val direction: Timeline.Direction) : RoomDetailActions()
|
||||
data class SendReaction(val targetEventId: String, val reaction: String) : RoomDetailActions()
|
||||
data class UndoReaction(val targetEventId: String, val reaction: String, val reason: String? = "") : RoomDetailActions()
|
||||
data class RedactAction(val targetEventId: String, val reason: String? = "") : RoomDetailActions()
|
||||
data class UpdateQuickReactAction(val targetEventId: String, val selectedReaction: String, val add: Boolean) : RoomDetailActions()
|
||||
data class NavigateToEvent(val eventId: String, val highlight: Boolean) : RoomDetailActions()
|
||||
data class SetReadMarkerAction(val eventId: String) : RoomDetailActions()
|
||||
object MarkAllAsRead : RoomDetailActions()
|
||||
data class DownloadFile(val eventId: String, val messageFileContent: MessageFileContent) : RoomDetailActions()
|
||||
data class HandleTombstoneEvent(val event: Event) : RoomDetailActions()
|
||||
object AcceptInvite : RoomDetailActions()
|
||||
object RejectInvite : RoomDetailActions()
|
||||
sealed class RoomDetailAction : VectorViewModelAction {
|
||||
data class SaveDraft(val draft: String) : RoomDetailAction()
|
||||
data class SendMessage(val text: String, val autoMarkdown: Boolean) : RoomDetailAction()
|
||||
data class SendMedia(val attachments: List<ContentAttachmentData>) : RoomDetailAction()
|
||||
data class TimelineEventTurnsVisible(val event: TimelineEvent) : RoomDetailAction()
|
||||
data class TimelineEventTurnsInvisible(val event: TimelineEvent) : RoomDetailAction()
|
||||
data class LoadMoreTimelineEvents(val direction: Timeline.Direction) : RoomDetailAction()
|
||||
data class SendReaction(val targetEventId: String, val reaction: String) : RoomDetailAction()
|
||||
data class UndoReaction(val targetEventId: String, val reaction: String, val reason: String? = "") : RoomDetailAction()
|
||||
data class RedactAction(val targetEventId: String, val reason: String? = "") : RoomDetailAction()
|
||||
data class UpdateQuickReactAction(val targetEventId: String, val selectedReaction: String, val add: Boolean) : RoomDetailAction()
|
||||
data class NavigateToEvent(val eventId: String, val highlight: Boolean) : RoomDetailAction()
|
||||
data class SetReadMarkerAction(val eventId: String) : RoomDetailAction()
|
||||
object MarkAllAsRead : RoomDetailAction()
|
||||
data class DownloadFile(val eventId: String, val messageFileContent: MessageFileContent) : RoomDetailAction()
|
||||
data class HandleTombstoneEvent(val event: Event) : RoomDetailAction()
|
||||
object AcceptInvite : RoomDetailAction()
|
||||
object RejectInvite : RoomDetailAction()
|
||||
|
||||
data class EnterEditMode(val eventId: String, val draft: String) : RoomDetailActions()
|
||||
data class EnterQuoteMode(val eventId: String, val draft: String) : RoomDetailActions()
|
||||
data class EnterReplyMode(val eventId: String, val draft: String) : RoomDetailActions()
|
||||
data class ExitSpecialMode(val draft: String) : RoomDetailActions()
|
||||
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 ResendMessage(val eventId: String) : RoomDetailActions()
|
||||
data class RemoveFailedEcho(val eventId: String) : RoomDetailActions()
|
||||
data class ResendMessage(val eventId: String) : RoomDetailAction()
|
||||
data class RemoveFailedEcho(val eventId: String) : RoomDetailAction()
|
||||
|
||||
data class ReportContent(
|
||||
val eventId: String,
|
||||
val senderId: String?,
|
||||
val reason: String,
|
||||
val spam: Boolean = false,
|
||||
val inappropriate: Boolean = false) : RoomDetailActions()
|
||||
val inappropriate: Boolean = false) : RoomDetailAction()
|
||||
|
||||
data class IgnoreUser(val userId: String?) : RoomDetailActions()
|
||||
data class IgnoreUser(val userId: String?) : RoomDetailAction()
|
||||
|
||||
object ClearSendQueue : RoomDetailActions()
|
||||
object ResendAll : RoomDetailActions()
|
||||
object ClearSendQueue : RoomDetailAction()
|
||||
object ResendAll : RoomDetailAction()
|
||||
}
|
|
@ -91,7 +91,7 @@ import im.vector.riotx.features.home.AvatarRenderer
|
|||
import im.vector.riotx.features.home.NavigateToRoomInterceptor
|
||||
import im.vector.riotx.features.home.PermalinkHandler
|
||||
import im.vector.riotx.features.home.getColorFromUserId
|
||||
import im.vector.riotx.features.home.room.detail.composer.TextComposerActions
|
||||
import im.vector.riotx.features.home.room.detail.composer.TextComposerAction
|
||||
import im.vector.riotx.features.home.room.detail.composer.TextComposerView
|
||||
import im.vector.riotx.features.home.room.detail.composer.TextComposerViewModel
|
||||
import im.vector.riotx.features.home.room.detail.composer.TextComposerViewState
|
||||
|
@ -278,8 +278,8 @@ class RoomDetailFragment @Inject constructor(
|
|||
|
||||
if (savedInstanceState == null) {
|
||||
when (val sharedData = roomDetailArgs.sharedData) {
|
||||
is SharedData.Text -> roomDetailViewModel.handle(RoomDetailActions.SendMessage(sharedData.text, false))
|
||||
is SharedData.Attachments -> roomDetailViewModel.handle(RoomDetailActions.SendMedia(sharedData.attachmentData))
|
||||
is SharedData.Text -> roomDetailViewModel.handle(RoomDetailAction.SendMessage(sharedData.text, false))
|
||||
is SharedData.Attachments -> roomDetailViewModel.handle(RoomDetailAction.SendMedia(sharedData.attachmentData))
|
||||
null -> Timber.v("No share data to process")
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
private fun setupNotificationView() {
|
||||
notificationAreaView.delegate = object : NotificationAreaView.Delegate {
|
||||
override fun onTombstoneEventClicked(tombstoneEvent: Event) {
|
||||
roomDetailViewModel.handle(RoomDetailActions.HandleTombstoneEvent(tombstoneEvent))
|
||||
roomDetailViewModel.handle(RoomDetailAction.HandleTombstoneEvent(tombstoneEvent))
|
||||
}
|
||||
|
||||
override fun resendUnsentEvents() {
|
||||
|
@ -355,11 +355,11 @@ class RoomDetailFragment @Inject constructor(
|
|||
// This a temporary option during dev as it is not super stable
|
||||
// Cancel all pending actions in room queue and post a dummy
|
||||
// Then mark all sending events as undelivered
|
||||
roomDetailViewModel.handle(RoomDetailActions.ClearSendQueue)
|
||||
roomDetailViewModel.handle(RoomDetailAction.ClearSendQueue)
|
||||
return true
|
||||
}
|
||||
if (item.itemId == R.id.resend_all) {
|
||||
roomDetailViewModel.handle(RoomDetailActions.ResendAll)
|
||||
roomDetailViewModel.handle(RoomDetailAction.ResendAll)
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
|
@ -427,7 +427,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
|
||||
notificationDrawerManager.setCurrentRoom(null)
|
||||
|
||||
roomDetailViewModel.handle(RoomDetailActions.SaveDraft(composerLayout.composerEditText.text.toString()))
|
||||
roomDetailViewModel.handle(RoomDetailAction.SaveDraft(composerLayout.composerEditText.text.toString()))
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
@ -440,7 +440,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
val reaction = data.getStringExtra(EmojiReactionPickerActivity.EXTRA_REACTION_RESULT)
|
||||
?: return
|
||||
// TODO check if already reacted with that?
|
||||
roomDetailViewModel.handle(RoomDetailActions.SendReaction(eventId, reaction))
|
||||
roomDetailViewModel.handle(RoomDetailAction.SendReaction(eventId, reaction))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
override fun performQuickReplyOnHolder(model: EpoxyModel<*>) {
|
||||
(model as? AbsMessageItem)?.attributes?.informationData?.let {
|
||||
val eventId = it.eventId
|
||||
roomDetailViewModel.handle(RoomDetailActions.EnterReplyMode(eventId, composerLayout.composerEditText.text.toString()))
|
||||
roomDetailViewModel.handle(RoomDetailAction.EnterReplyMode(eventId, composerLayout.composerEditText.text.toString()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,11 +601,11 @@ class RoomDetailFragment @Inject constructor(
|
|||
val textMessage = composerLayout.composerEditText.text.toString()
|
||||
if (textMessage.isNotBlank()) {
|
||||
lockSendButton = true
|
||||
roomDetailViewModel.handle(RoomDetailActions.SendMessage(textMessage, vectorPreferences.isMarkdownEnabled()))
|
||||
roomDetailViewModel.handle(RoomDetailAction.SendMessage(textMessage, vectorPreferences.isMarkdownEnabled()))
|
||||
}
|
||||
}
|
||||
composerLayout.composerRelatedMessageCloseButton.setOnClickListener {
|
||||
roomDetailViewModel.handle(RoomDetailActions.ExitSpecialMode(composerLayout.composerEditText.text.toString()))
|
||||
roomDetailViewModel.handle(RoomDetailAction.ExitSpecialMode(composerLayout.composerEditText.text.toString()))
|
||||
}
|
||||
composerLayout.callback = object : TextComposerView.Callback {
|
||||
override fun onRichContentSelected(contentUri: Uri): Boolean {
|
||||
|
@ -760,13 +760,13 @@ class RoomDetailFragment @Inject constructor(
|
|||
.setView(layout)
|
||||
.setPositiveButton(R.string.report_content_custom_submit) { _, _ ->
|
||||
val reason = input.text.toString()
|
||||
roomDetailViewModel.handle(RoomDetailActions.ReportContent(action.eventId, action.senderId, reason))
|
||||
roomDetailViewModel.handle(RoomDetailAction.ReportContent(action.eventId, action.senderId, reason))
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun displayRoomDetailActionResult(result: Async<RoomDetailActions>) {
|
||||
private fun displayRoomDetailActionResult(result: Async<RoomDetailAction>) {
|
||||
when (result) {
|
||||
is Fail -> {
|
||||
AlertDialog.Builder(requireActivity())
|
||||
|
@ -777,7 +777,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
is Success -> {
|
||||
when (val data = result.invoke()) {
|
||||
is RoomDetailActions.ReportContent -> {
|
||||
is RoomDetailAction.ReportContent -> {
|
||||
when {
|
||||
data.spam -> {
|
||||
AlertDialog.Builder(requireActivity())
|
||||
|
@ -785,7 +785,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
.setMessage(R.string.content_reported_as_spam_content)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.block_user) { _, _ ->
|
||||
roomDetailViewModel.handle(RoomDetailActions.IgnoreUser(data.senderId))
|
||||
roomDetailViewModel.handle(RoomDetailAction.IgnoreUser(data.senderId))
|
||||
}
|
||||
.show()
|
||||
.withColoredButton(DialogInterface.BUTTON_NEGATIVE)
|
||||
|
@ -796,7 +796,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
.setMessage(R.string.content_reported_as_inappropriate_content)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.block_user) { _, _ ->
|
||||
roomDetailViewModel.handle(RoomDetailActions.IgnoreUser(data.senderId))
|
||||
roomDetailViewModel.handle(RoomDetailAction.IgnoreUser(data.senderId))
|
||||
}
|
||||
.show()
|
||||
.withColoredButton(DialogInterface.BUTTON_NEGATIVE)
|
||||
|
@ -807,7 +807,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
.setMessage(R.string.content_reported_content)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.block_user) { _, _ ->
|
||||
roomDetailViewModel.handle(RoomDetailActions.IgnoreUser(data.senderId))
|
||||
roomDetailViewModel.handle(RoomDetailAction.IgnoreUser(data.senderId))
|
||||
}
|
||||
.show()
|
||||
.withColoredButton(DialogInterface.BUTTON_NEGATIVE)
|
||||
|
@ -831,7 +831,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
showSnackWithMessage(getString(R.string.navigate_to_room_when_already_in_the_room))
|
||||
} else {
|
||||
// Highlight and scroll to this event
|
||||
roomDetailViewModel.handle(RoomDetailActions.NavigateToEvent(eventId, true))
|
||||
roomDetailViewModel.handle(RoomDetailAction.NavigateToEvent(eventId, true))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -859,11 +859,11 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onEventVisible(event: TimelineEvent) {
|
||||
roomDetailViewModel.handle(RoomDetailActions.TimelineEventTurnsVisible(event))
|
||||
roomDetailViewModel.handle(RoomDetailAction.TimelineEventTurnsVisible(event))
|
||||
}
|
||||
|
||||
override fun onEventInvisible(event: TimelineEvent) {
|
||||
roomDetailViewModel.handle(RoomDetailActions.TimelineEventTurnsInvisible(event))
|
||||
roomDetailViewModel.handle(RoomDetailAction.TimelineEventTurnsInvisible(event))
|
||||
}
|
||||
|
||||
override fun onEncryptedMessageClicked(informationData: MessageInformationData, view: View) {
|
||||
|
@ -899,7 +899,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onFileMessageClicked(eventId: String, messageFileContent: MessageFileContent) {
|
||||
val action = RoomDetailActions.DownloadFile(eventId, messageFileContent)
|
||||
val action = RoomDetailAction.DownloadFile(eventId, messageFileContent)
|
||||
// We need WRITE_EXTERNAL permission
|
||||
if (checkPermissions(PERMISSIONS_FOR_WRITING_FILES, this, PERMISSION_REQUEST_CODE_DOWNLOAD_FILE)) {
|
||||
roomDetailViewModel.handle(action)
|
||||
|
@ -946,7 +946,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onLoadMore(direction: Timeline.Direction) {
|
||||
roomDetailViewModel.handle(RoomDetailActions.LoadMoreTimelineEvents(direction))
|
||||
roomDetailViewModel.handle(RoomDetailAction.LoadMoreTimelineEvents(direction))
|
||||
}
|
||||
|
||||
override fun onEventCellClicked(informationData: MessageInformationData, messageContent: MessageContent?, view: View) {
|
||||
|
@ -976,10 +976,10 @@ class RoomDetailFragment @Inject constructor(
|
|||
override fun onClickOnReactionPill(informationData: MessageInformationData, reaction: String, on: Boolean) {
|
||||
if (on) {
|
||||
// we should test the current real state of reaction on this event
|
||||
roomDetailViewModel.handle(RoomDetailActions.SendReaction(informationData.eventId, reaction))
|
||||
roomDetailViewModel.handle(RoomDetailAction.SendReaction(informationData.eventId, reaction))
|
||||
} else {
|
||||
// I need to redact a reaction
|
||||
roomDetailViewModel.handle(RoomDetailActions.UndoReaction(informationData.eventId, reaction))
|
||||
roomDetailViewModel.handle(RoomDetailAction.UndoReaction(informationData.eventId, reaction))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1027,14 +1027,14 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
}
|
||||
if (nextReadMarkerId != null) {
|
||||
roomDetailViewModel.handle(RoomDetailActions.SetReadMarkerAction(nextReadMarkerId))
|
||||
roomDetailViewModel.handle(RoomDetailAction.SetReadMarkerAction(nextReadMarkerId))
|
||||
}
|
||||
}
|
||||
|
||||
// AutocompleteUserPresenter.Callback
|
||||
|
||||
override fun onQueryUsers(query: CharSequence?) {
|
||||
textComposerViewModel.handle(TextComposerActions.QueryUsers(query))
|
||||
textComposerViewModel.handle(TextComposerAction.QueryUsers(query))
|
||||
}
|
||||
|
||||
private fun handleActions(action: EventSharedAction) {
|
||||
|
@ -1053,7 +1053,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
showSnackWithMessage(msg, Snackbar.LENGTH_SHORT)
|
||||
}
|
||||
is EventSharedAction.Delete -> {
|
||||
roomDetailViewModel.handle(RoomDetailActions.RedactAction(action.eventId, context?.getString(R.string.event_redacted_by_user_reason)))
|
||||
roomDetailViewModel.handle(RoomDetailAction.RedactAction(action.eventId, context?.getString(R.string.event_redacted_by_user_reason)))
|
||||
}
|
||||
is EventSharedAction.Share -> {
|
||||
// TODO current data communication is too limited
|
||||
|
@ -1110,16 +1110,16 @@ class RoomDetailFragment @Inject constructor(
|
|||
}
|
||||
is EventSharedAction.QuickReact -> {
|
||||
// eventId,ClickedOn,Add
|
||||
roomDetailViewModel.handle(RoomDetailActions.UpdateQuickReactAction(action.eventId, action.clickedOn, action.add))
|
||||
roomDetailViewModel.handle(RoomDetailAction.UpdateQuickReactAction(action.eventId, action.clickedOn, action.add))
|
||||
}
|
||||
is EventSharedAction.Edit -> {
|
||||
roomDetailViewModel.handle(RoomDetailActions.EnterEditMode(action.eventId, composerLayout.composerEditText.text.toString()))
|
||||
roomDetailViewModel.handle(RoomDetailAction.EnterEditMode(action.eventId, composerLayout.composerEditText.text.toString()))
|
||||
}
|
||||
is EventSharedAction.Quote -> {
|
||||
roomDetailViewModel.handle(RoomDetailActions.EnterQuoteMode(action.eventId, composerLayout.composerEditText.text.toString()))
|
||||
roomDetailViewModel.handle(RoomDetailAction.EnterQuoteMode(action.eventId, composerLayout.composerEditText.text.toString()))
|
||||
}
|
||||
is EventSharedAction.Reply -> {
|
||||
roomDetailViewModel.handle(RoomDetailActions.EnterReplyMode(action.eventId, composerLayout.composerEditText.text.toString()))
|
||||
roomDetailViewModel.handle(RoomDetailAction.EnterReplyMode(action.eventId, composerLayout.composerEditText.text.toString()))
|
||||
}
|
||||
is EventSharedAction.CopyPermalink -> {
|
||||
val permalink = PermalinkFactory.createPermalink(roomDetailArgs.roomId, action.eventId)
|
||||
|
@ -1127,17 +1127,17 @@ class RoomDetailFragment @Inject constructor(
|
|||
showSnackWithMessage(requireContext().getString(R.string.copied_to_clipboard), Snackbar.LENGTH_SHORT)
|
||||
}
|
||||
is EventSharedAction.Resend -> {
|
||||
roomDetailViewModel.handle(RoomDetailActions.ResendMessage(action.eventId))
|
||||
roomDetailViewModel.handle(RoomDetailAction.ResendMessage(action.eventId))
|
||||
}
|
||||
is EventSharedAction.Remove -> {
|
||||
roomDetailViewModel.handle(RoomDetailActions.RemoveFailedEcho(action.eventId))
|
||||
roomDetailViewModel.handle(RoomDetailAction.RemoveFailedEcho(action.eventId))
|
||||
}
|
||||
is EventSharedAction.ReportContentSpam -> {
|
||||
roomDetailViewModel.handle(RoomDetailActions.ReportContent(
|
||||
roomDetailViewModel.handle(RoomDetailAction.ReportContent(
|
||||
action.eventId, action.senderId, "This message is spam", spam = true))
|
||||
}
|
||||
is EventSharedAction.ReportContentInappropriate -> {
|
||||
roomDetailViewModel.handle(RoomDetailActions.ReportContent(
|
||||
roomDetailViewModel.handle(RoomDetailAction.ReportContent(
|
||||
action.eventId, action.senderId, "This message is inappropriate", inappropriate = true))
|
||||
}
|
||||
is EventSharedAction.ReportContentCustom -> {
|
||||
|
@ -1210,22 +1210,22 @@ class RoomDetailFragment @Inject constructor(
|
|||
|
||||
override fun onAcceptInvite() {
|
||||
notificationDrawerManager.clearMemberShipNotificationForRoom(roomDetailArgs.roomId)
|
||||
roomDetailViewModel.handle(RoomDetailActions.AcceptInvite)
|
||||
roomDetailViewModel.handle(RoomDetailAction.AcceptInvite)
|
||||
}
|
||||
|
||||
override fun onRejectInvite() {
|
||||
notificationDrawerManager.clearMemberShipNotificationForRoom(roomDetailArgs.roomId)
|
||||
roomDetailViewModel.handle(RoomDetailActions.RejectInvite)
|
||||
roomDetailViewModel.handle(RoomDetailAction.RejectInvite)
|
||||
}
|
||||
|
||||
// JumpToReadMarkerView.Callback
|
||||
|
||||
override fun onJumpToReadMarkerClicked(readMarkerId: String) {
|
||||
roomDetailViewModel.handle(RoomDetailActions.NavigateToEvent(readMarkerId, false))
|
||||
roomDetailViewModel.handle(RoomDetailAction.NavigateToEvent(readMarkerId, false))
|
||||
}
|
||||
|
||||
override fun onClearReadMarkerClicked() {
|
||||
roomDetailViewModel.handle(RoomDetailActions.MarkAllAsRead)
|
||||
roomDetailViewModel.handle(RoomDetailAction.MarkAllAsRead)
|
||||
}
|
||||
|
||||
// AttachmentTypeSelectorView.Callback
|
||||
|
@ -1252,7 +1252,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
// AttachmentsHelper.Callback
|
||||
|
||||
override fun onContentAttachmentsReady(attachments: List<ContentAttachmentData>) {
|
||||
roomDetailViewModel.handle(RoomDetailActions.SendMedia(attachments))
|
||||
roomDetailViewModel.handle(RoomDetailAction.SendMedia(attachments))
|
||||
}
|
||||
|
||||
override fun onAttachmentsProcessFailed() {
|
||||
|
@ -1262,6 +1262,6 @@ class RoomDetailFragment @Inject constructor(
|
|||
override fun onContactAttachmentReady(contactAttachment: ContactAttachment) {
|
||||
super.onContactAttachmentReady(contactAttachment)
|
||||
val formattedContact = contactAttachment.toHumanReadable()
|
||||
roomDetailViewModel.handle(RoomDetailActions.SendMessage(formattedContact, false))
|
||||
roomDetailViewModel.handle(RoomDetailAction.SendMessage(formattedContact, false))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,12 +69,12 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
private val vectorPreferences: VectorPreferences,
|
||||
private val stringProvider: StringProvider,
|
||||
private val session: Session
|
||||
) : VectorViewModel<RoomDetailViewState, RoomDetailActions>(initialState) {
|
||||
) : VectorViewModel<RoomDetailViewState, RoomDetailAction>(initialState) {
|
||||
|
||||
private val room = session.getRoom(initialState.roomId)!!
|
||||
private val eventId = initialState.eventId
|
||||
private val invisibleEventsObservable = BehaviorRelay.create<RoomDetailActions.TimelineEventTurnsInvisible>()
|
||||
private val visibleEventsObservable = BehaviorRelay.create<RoomDetailActions.TimelineEventTurnsVisible>()
|
||||
private val invisibleEventsObservable = BehaviorRelay.create<RoomDetailAction.TimelineEventTurnsInvisible>()
|
||||
private val visibleEventsObservable = BehaviorRelay.create<RoomDetailAction.TimelineEventTurnsVisible>()
|
||||
private val timelineSettings = if (userPreferencesProvider.shouldShowHiddenEvents()) {
|
||||
TimelineSettings(30,
|
||||
filterEdits = false,
|
||||
|
@ -92,12 +92,12 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
private var timeline = room.createTimeline(eventId, timelineSettings)
|
||||
|
||||
// Can be used for several actions, for a one shot result
|
||||
private val _requestLiveData = MutableLiveData<LiveEvent<Async<RoomDetailActions>>>()
|
||||
val requestLiveData: LiveData<LiveEvent<Async<RoomDetailActions>>>
|
||||
private val _requestLiveData = MutableLiveData<LiveEvent<Async<RoomDetailAction>>>()
|
||||
val requestLiveData: LiveData<LiveEvent<Async<RoomDetailAction>>>
|
||||
get() = _requestLiveData
|
||||
|
||||
// Slot to keep a pending action during permission request
|
||||
var pendingAction: RoomDetailActions? = null
|
||||
var pendingAction: RoomDetailAction? = null
|
||||
// Slot to keep a pending uri during permission request
|
||||
var pendingUri: Uri? = null
|
||||
|
||||
|
@ -129,46 +129,46 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
setState { copy(timeline = this@RoomDetailViewModel.timeline) }
|
||||
}
|
||||
|
||||
override fun handle(action: RoomDetailActions) {
|
||||
override fun handle(action: RoomDetailAction) {
|
||||
when (action) {
|
||||
is RoomDetailActions.SaveDraft -> handleSaveDraft(action)
|
||||
is RoomDetailActions.SendMessage -> handleSendMessage(action)
|
||||
is RoomDetailActions.SendMedia -> handleSendMedia(action)
|
||||
is RoomDetailActions.TimelineEventTurnsVisible -> handleEventVisible(action)
|
||||
is RoomDetailActions.TimelineEventTurnsInvisible -> handleEventInvisible(action)
|
||||
is RoomDetailActions.LoadMoreTimelineEvents -> handleLoadMore(action)
|
||||
is RoomDetailActions.SendReaction -> handleSendReaction(action)
|
||||
is RoomDetailActions.AcceptInvite -> handleAcceptInvite()
|
||||
is RoomDetailActions.RejectInvite -> handleRejectInvite()
|
||||
is RoomDetailActions.RedactAction -> handleRedactEvent(action)
|
||||
is RoomDetailActions.UndoReaction -> handleUndoReact(action)
|
||||
is RoomDetailActions.UpdateQuickReactAction -> handleUpdateQuickReaction(action)
|
||||
is RoomDetailActions.ExitSpecialMode -> handleExitSpecialMode(action)
|
||||
is RoomDetailActions.EnterEditMode -> handleEditAction(action)
|
||||
is RoomDetailActions.EnterQuoteMode -> handleQuoteAction(action)
|
||||
is RoomDetailActions.EnterReplyMode -> handleReplyAction(action)
|
||||
is RoomDetailActions.DownloadFile -> handleDownloadFile(action)
|
||||
is RoomDetailActions.NavigateToEvent -> handleNavigateToEvent(action)
|
||||
is RoomDetailActions.HandleTombstoneEvent -> handleTombstoneEvent(action)
|
||||
is RoomDetailActions.ResendMessage -> handleResendEvent(action)
|
||||
is RoomDetailActions.RemoveFailedEcho -> handleRemove(action)
|
||||
is RoomDetailActions.ClearSendQueue -> handleClearSendQueue()
|
||||
is RoomDetailActions.ResendAll -> handleResendAll()
|
||||
is RoomDetailActions.SetReadMarkerAction -> handleSetReadMarkerAction(action)
|
||||
is RoomDetailActions.MarkAllAsRead -> handleMarkAllAsRead()
|
||||
is RoomDetailActions.ReportContent -> handleReportContent(action)
|
||||
is RoomDetailActions.IgnoreUser -> handleIgnoreUser(action)
|
||||
is RoomDetailAction.SaveDraft -> handleSaveDraft(action)
|
||||
is RoomDetailAction.SendMessage -> handleSendMessage(action)
|
||||
is RoomDetailAction.SendMedia -> handleSendMedia(action)
|
||||
is RoomDetailAction.TimelineEventTurnsVisible -> handleEventVisible(action)
|
||||
is RoomDetailAction.TimelineEventTurnsInvisible -> handleEventInvisible(action)
|
||||
is RoomDetailAction.LoadMoreTimelineEvents -> handleLoadMore(action)
|
||||
is RoomDetailAction.SendReaction -> handleSendReaction(action)
|
||||
is RoomDetailAction.AcceptInvite -> handleAcceptInvite()
|
||||
is RoomDetailAction.RejectInvite -> handleRejectInvite()
|
||||
is RoomDetailAction.RedactAction -> handleRedactEvent(action)
|
||||
is RoomDetailAction.UndoReaction -> handleUndoReact(action)
|
||||
is RoomDetailAction.UpdateQuickReactAction -> handleUpdateQuickReaction(action)
|
||||
is RoomDetailAction.ExitSpecialMode -> handleExitSpecialMode(action)
|
||||
is RoomDetailAction.EnterEditMode -> handleEditAction(action)
|
||||
is RoomDetailAction.EnterQuoteMode -> handleQuoteAction(action)
|
||||
is RoomDetailAction.EnterReplyMode -> handleReplyAction(action)
|
||||
is RoomDetailAction.DownloadFile -> handleDownloadFile(action)
|
||||
is RoomDetailAction.NavigateToEvent -> handleNavigateToEvent(action)
|
||||
is RoomDetailAction.HandleTombstoneEvent -> handleTombstoneEvent(action)
|
||||
is RoomDetailAction.ResendMessage -> handleResendEvent(action)
|
||||
is RoomDetailAction.RemoveFailedEcho -> handleRemove(action)
|
||||
is RoomDetailAction.ClearSendQueue -> handleClearSendQueue()
|
||||
is RoomDetailAction.ResendAll -> handleResendAll()
|
||||
is RoomDetailAction.SetReadMarkerAction -> handleSetReadMarkerAction(action)
|
||||
is RoomDetailAction.MarkAllAsRead -> handleMarkAllAsRead()
|
||||
is RoomDetailAction.ReportContent -> handleReportContent(action)
|
||||
is RoomDetailAction.IgnoreUser -> handleIgnoreUser(action)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleEventInvisible(action: RoomDetailActions.TimelineEventTurnsInvisible) {
|
||||
private fun handleEventInvisible(action: RoomDetailAction.TimelineEventTurnsInvisible) {
|
||||
invisibleEventsObservable.accept(action)
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a send mode to a draft and save the draft
|
||||
*/
|
||||
private fun handleSaveDraft(action: RoomDetailActions.SaveDraft) {
|
||||
private fun handleSaveDraft(action: RoomDetailAction.SaveDraft) {
|
||||
withState {
|
||||
when (it.sendMode) {
|
||||
is SendMode.REGULAR -> room.saveDraft(UserDraft.REGULAR(action.draft))
|
||||
|
@ -211,7 +211,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
.disposeOnClear()
|
||||
}
|
||||
|
||||
private fun handleTombstoneEvent(action: RoomDetailActions.HandleTombstoneEvent) {
|
||||
private fun handleTombstoneEvent(action: RoomDetailAction.HandleTombstoneEvent) {
|
||||
val tombstoneContent = action.event.getClearContent().toModel<RoomTombstoneContent>()
|
||||
?: return
|
||||
|
||||
|
@ -267,7 +267,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
|
||||
// PRIVATE METHODS *****************************************************************************
|
||||
|
||||
private fun handleSendMessage(action: RoomDetailActions.SendMessage) {
|
||||
private fun handleSendMessage(action: RoomDetailAction.SendMessage) {
|
||||
withState { state ->
|
||||
when (state.sendMode) {
|
||||
is SendMode.REGULAR -> {
|
||||
|
@ -458,20 +458,20 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
})
|
||||
}
|
||||
|
||||
private fun handleSendReaction(action: RoomDetailActions.SendReaction) {
|
||||
private fun handleSendReaction(action: RoomDetailAction.SendReaction) {
|
||||
room.sendReaction(action.targetEventId, action.reaction)
|
||||
}
|
||||
|
||||
private fun handleRedactEvent(action: RoomDetailActions.RedactAction) {
|
||||
private fun handleRedactEvent(action: RoomDetailAction.RedactAction) {
|
||||
val event = room.getTimeLineEvent(action.targetEventId) ?: return
|
||||
room.redactEvent(event.root, action.reason)
|
||||
}
|
||||
|
||||
private fun handleUndoReact(action: RoomDetailActions.UndoReaction) {
|
||||
private fun handleUndoReact(action: RoomDetailAction.UndoReaction) {
|
||||
room.undoReaction(action.targetEventId, action.reaction)
|
||||
}
|
||||
|
||||
private fun handleUpdateQuickReaction(action: RoomDetailActions.UpdateQuickReactAction) {
|
||||
private fun handleUpdateQuickReaction(action: RoomDetailAction.UpdateQuickReactAction) {
|
||||
if (action.add) {
|
||||
room.sendReaction(action.targetEventId, action.selectedReaction)
|
||||
} else {
|
||||
|
@ -479,7 +479,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleSendMedia(action: RoomDetailActions.SendMedia) {
|
||||
private fun handleSendMedia(action: RoomDetailAction.SendMedia) {
|
||||
val attachments = action.attachments
|
||||
val homeServerCapabilities = session.getHomeServerCapabilities()
|
||||
val maxUploadFileSize = homeServerCapabilities.maxUploadFileSize
|
||||
|
@ -496,19 +496,19 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleEventVisible(action: RoomDetailActions.TimelineEventTurnsVisible) {
|
||||
private fun handleEventVisible(action: RoomDetailAction.TimelineEventTurnsVisible) {
|
||||
if (action.event.root.sendState.isSent()) { // ignore pending/local events
|
||||
visibleEventsObservable.accept(action)
|
||||
}
|
||||
// We need to update this with the related m.replace also (to move read receipt)
|
||||
action.event.annotations?.editSummary?.sourceEvents?.forEach {
|
||||
room.getTimeLineEvent(it)?.let { event ->
|
||||
visibleEventsObservable.accept(RoomDetailActions.TimelineEventTurnsVisible(event))
|
||||
visibleEventsObservable.accept(RoomDetailAction.TimelineEventTurnsVisible(event))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleLoadMore(action: RoomDetailActions.LoadMoreTimelineEvents) {
|
||||
private fun handleLoadMore(action: RoomDetailAction.LoadMoreTimelineEvents) {
|
||||
timeline.paginate(action.direction, PAGINATION_COUNT)
|
||||
}
|
||||
|
||||
|
@ -520,7 +520,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
room.join(callback = object : MatrixCallback<Unit> {})
|
||||
}
|
||||
|
||||
private fun handleEditAction(action: RoomDetailActions.EnterEditMode) {
|
||||
private fun handleEditAction(action: RoomDetailAction.EnterEditMode) {
|
||||
saveCurrentDraft(action.draft)
|
||||
|
||||
room.getTimeLineEvent(action.eventId)?.let { timelineEvent ->
|
||||
|
@ -530,7 +530,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleQuoteAction(action: RoomDetailActions.EnterQuoteMode) {
|
||||
private fun handleQuoteAction(action: RoomDetailAction.EnterQuoteMode) {
|
||||
saveCurrentDraft(action.draft)
|
||||
|
||||
room.getTimeLineEvent(action.eventId)?.let { timelineEvent ->
|
||||
|
@ -547,7 +547,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleReplyAction(action: RoomDetailActions.EnterReplyMode) {
|
||||
private fun handleReplyAction(action: RoomDetailAction.EnterReplyMode) {
|
||||
saveCurrentDraft(action.draft)
|
||||
|
||||
room.getTimeLineEvent(action.eventId)?.let { timelineEvent ->
|
||||
|
@ -578,7 +578,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleExitSpecialMode(action: RoomDetailActions.ExitSpecialMode) {
|
||||
private fun handleExitSpecialMode(action: RoomDetailAction.ExitSpecialMode) {
|
||||
withState { state ->
|
||||
// For edit, just delete the current draft
|
||||
if (state.sendMode is SendMode.EDIT) {
|
||||
|
@ -590,7 +590,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleDownloadFile(action: RoomDetailActions.DownloadFile) {
|
||||
private fun handleDownloadFile(action: RoomDetailAction.DownloadFile) {
|
||||
session.downloadFile(
|
||||
FileService.DownloadMode.TO_EXPORT,
|
||||
action.eventId,
|
||||
|
@ -616,7 +616,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
})
|
||||
}
|
||||
|
||||
private fun handleNavigateToEvent(action: RoomDetailActions.NavigateToEvent) {
|
||||
private fun handleNavigateToEvent(action: RoomDetailAction.NavigateToEvent) {
|
||||
val targetEventId: String = action.eventId
|
||||
val correctedEventId = timeline.getFirstDisplayableEventId(targetEventId) ?: targetEventId
|
||||
val indexOfEvent = timeline.getIndexOfEvent(correctedEventId)
|
||||
|
@ -630,7 +630,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
_navigateToEvent.postLiveEvent(correctedEventId)
|
||||
}
|
||||
|
||||
private fun handleResendEvent(action: RoomDetailActions.ResendMessage) {
|
||||
private fun handleResendEvent(action: RoomDetailAction.ResendMessage) {
|
||||
val targetEventId = action.eventId
|
||||
room.getTimeLineEvent(targetEventId)?.let {
|
||||
// State must be UNDELIVERED or Failed
|
||||
|
@ -648,7 +648,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleRemove(action: RoomDetailActions.RemoveFailedEcho) {
|
||||
private fun handleRemove(action: RoomDetailAction.RemoveFailedEcho) {
|
||||
val targetEventId = action.eventId
|
||||
room.getTimeLineEvent(targetEventId)?.let {
|
||||
// State must be UNDELIVERED or Failed
|
||||
|
@ -683,7 +683,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
.disposeOnClear()
|
||||
}
|
||||
|
||||
private fun handleSetReadMarkerAction(action: RoomDetailActions.SetReadMarkerAction) = withState {
|
||||
private fun handleSetReadMarkerAction(action: RoomDetailAction.SetReadMarkerAction) = withState {
|
||||
var readMarkerId = action.eventId
|
||||
val indexOfEvent = timeline.getIndexOfEvent(readMarkerId)
|
||||
// force to set the read marker on the next event
|
||||
|
@ -699,7 +699,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
room.markAllAsRead(object : MatrixCallback<Any> {})
|
||||
}
|
||||
|
||||
private fun handleReportContent(action: RoomDetailActions.ReportContent) {
|
||||
private fun handleReportContent(action: RoomDetailAction.ReportContent) {
|
||||
room.reportContent(action.eventId, -100, action.reason, object : MatrixCallback<Unit> {
|
||||
override fun onSuccess(data: Unit) {
|
||||
_requestLiveData.postValue(LiveEvent(Success(action)))
|
||||
|
@ -711,7 +711,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||
})
|
||||
}
|
||||
|
||||
private fun handleIgnoreUser(action: RoomDetailActions.IgnoreUser) {
|
||||
private fun handleIgnoreUser(action: RoomDetailAction.IgnoreUser) {
|
||||
if (action.userId.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ package im.vector.riotx.features.home.room.detail.composer
|
|||
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class TextComposerActions : VectorViewModelAction {
|
||||
data class QueryUsers(val query: CharSequence?) : TextComposerActions()
|
||||
sealed class TextComposerAction : VectorViewModelAction {
|
||||
data class QueryUsers(val query: CharSequence?) : TextComposerAction()
|
||||
}
|
|
@ -36,7 +36,7 @@ typealias AutocompleteUserQuery = CharSequence
|
|||
|
||||
class TextComposerViewModel @AssistedInject constructor(@Assisted initialState: TextComposerViewState,
|
||||
private val session: Session
|
||||
) : VectorViewModel<TextComposerViewState, TextComposerActions>(initialState) {
|
||||
) : VectorViewModel<TextComposerViewState, TextComposerAction>(initialState) {
|
||||
|
||||
private val room = session.getRoom(initialState.roomId)!!
|
||||
private val roomId = initialState.roomId
|
||||
|
@ -61,13 +61,13 @@ class TextComposerViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
observeUsersQuery()
|
||||
}
|
||||
|
||||
override fun handle(action: TextComposerActions) {
|
||||
override fun handle(action: TextComposerAction) {
|
||||
when (action) {
|
||||
is TextComposerActions.QueryUsers -> handleQueryUsers(action)
|
||||
is TextComposerAction.QueryUsers -> handleQueryUsers(action)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleQueryUsers(action: TextComposerActions.QueryUsers) {
|
||||
private fun handleQueryUsers(action: TextComposerAction.QueryUsers) {
|
||||
val query = Option.fromNullable(action.query)
|
||||
usersQueryObservable.accept(query)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ package im.vector.riotx.features.home.room.detail.timeline.action
|
|||
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class MessageActionsActions : VectorViewModelAction {
|
||||
object ToggleReportMenu : MessageActionsActions()
|
||||
sealed class MessageActionsAction : VectorViewModelAction {
|
||||
object ToggleReportMenu : MessageActionsAction()
|
||||
}
|
|
@ -72,7 +72,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
|
|||
override fun didSelectMenuAction(eventAction: EventSharedAction) {
|
||||
if (eventAction is EventSharedAction.ReportContent) {
|
||||
// Toggle report menu
|
||||
viewModel.handle(MessageActionsActions.ToggleReportMenu)
|
||||
viewModel.handle(MessageActionsAction.ToggleReportMenu)
|
||||
} else {
|
||||
messageActionsStore.post(eventAction)
|
||||
dismiss()
|
||||
|
|
|
@ -85,7 +85,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
|||
private val session: Session,
|
||||
private val noticeEventFormatter: NoticeEventFormatter,
|
||||
private val stringProvider: StringProvider
|
||||
) : VectorViewModel<MessageActionState, MessageActionsActions>(initialState) {
|
||||
) : VectorViewModel<MessageActionState, MessageActionsAction>(initialState) {
|
||||
|
||||
private val eventId = initialState.eventId
|
||||
private val informationData = initialState.informationData
|
||||
|
@ -112,9 +112,9 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
|||
observeEventAction()
|
||||
}
|
||||
|
||||
override fun handle(action: MessageActionsActions) {
|
||||
override fun handle(action: MessageActionsAction) {
|
||||
when (action) {
|
||||
MessageActionsActions.ToggleReportMenu -> toggleReportMenu()
|
||||
MessageActionsAction.ToggleReportMenu -> toggleReportMenu()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ import im.vector.matrix.android.api.session.room.model.RoomSummary
|
|||
import im.vector.matrix.android.api.session.room.notification.RoomNotificationState
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class RoomListActions : VectorViewModelAction {
|
||||
data class SelectRoom(val roomSummary: RoomSummary) : RoomListActions()
|
||||
data class ToggleCategory(val category: RoomCategory) : RoomListActions()
|
||||
data class AcceptInvitation(val roomSummary: RoomSummary) : RoomListActions()
|
||||
data class RejectInvitation(val roomSummary: RoomSummary) : RoomListActions()
|
||||
data class FilterWith(val filter: String) : RoomListActions()
|
||||
data class ChangeRoomNotificationState(val roomId: String, val notificationState: RoomNotificationState) : RoomListActions()
|
||||
data class LeaveRoom(val roomId: String) : RoomListActions()
|
||||
object MarkAllRoomsRead : RoomListActions()
|
||||
sealed class RoomListAction : VectorViewModelAction {
|
||||
data class SelectRoom(val roomSummary: RoomSummary) : RoomListAction()
|
||||
data class ToggleCategory(val category: RoomCategory) : RoomListAction()
|
||||
data class AcceptInvitation(val roomSummary: RoomSummary) : RoomListAction()
|
||||
data class RejectInvitation(val roomSummary: RoomSummary) : RoomListAction()
|
||||
data class FilterWith(val filter: String) : RoomListAction()
|
||||
data class ChangeRoomNotificationState(val roomId: String, val notificationState: RoomNotificationState) : RoomListAction()
|
||||
data class LeaveRoom(val roomId: String) : RoomListAction()
|
||||
object MarkAllRoomsRead : RoomListAction()
|
||||
}
|
|
@ -85,7 +85,7 @@ class RoomListFragment @Inject constructor(
|
|||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.menu_home_mark_all_as_read -> {
|
||||
roomListViewModel.handle(RoomListActions.MarkAllRoomsRead)
|
||||
roomListViewModel.handle(RoomListAction.MarkAllRoomsRead)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ class RoomListFragment @Inject constructor(
|
|||
// Scroll the list to top
|
||||
roomListEpoxyRecyclerView.scrollToPosition(0)
|
||||
|
||||
roomListViewModel.handle(RoomListActions.FilterWith(filter))
|
||||
roomListViewModel.handle(RoomListAction.FilterWith(filter))
|
||||
}
|
||||
|
||||
override fun openRoomDirectory(initialFilter: String) {
|
||||
|
@ -219,16 +219,16 @@ class RoomListFragment @Inject constructor(
|
|||
private fun handleQuickActions(quickAction: RoomListQuickActionsSharedAction) {
|
||||
when (quickAction) {
|
||||
is RoomListQuickActionsSharedAction.NotificationsAllNoisy -> {
|
||||
roomListViewModel.handle(RoomListActions.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.ALL_MESSAGES_NOISY))
|
||||
roomListViewModel.handle(RoomListAction.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.ALL_MESSAGES_NOISY))
|
||||
}
|
||||
is RoomListQuickActionsSharedAction.NotificationsAll -> {
|
||||
roomListViewModel.handle(RoomListActions.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.ALL_MESSAGES))
|
||||
roomListViewModel.handle(RoomListAction.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.ALL_MESSAGES))
|
||||
}
|
||||
is RoomListQuickActionsSharedAction.NotificationsMentionsOnly -> {
|
||||
roomListViewModel.handle(RoomListActions.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.MENTIONS_ONLY))
|
||||
roomListViewModel.handle(RoomListAction.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.MENTIONS_ONLY))
|
||||
}
|
||||
is RoomListQuickActionsSharedAction.NotificationsMute -> {
|
||||
roomListViewModel.handle(RoomListActions.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.MUTE))
|
||||
roomListViewModel.handle(RoomListAction.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.MUTE))
|
||||
}
|
||||
is RoomListQuickActionsSharedAction.Settings -> {
|
||||
vectorBaseActivity.notImplemented("Opening room settings")
|
||||
|
@ -238,7 +238,7 @@ class RoomListFragment @Inject constructor(
|
|||
.setTitle(R.string.room_participants_leave_prompt_title)
|
||||
.setMessage(R.string.room_participants_leave_prompt_msg)
|
||||
.setPositiveButton(R.string.leave) { _, _ ->
|
||||
roomListViewModel.handle(RoomListActions.LeaveRoom(quickAction.roomId))
|
||||
roomListViewModel.handle(RoomListAction.LeaveRoom(quickAction.roomId))
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show()
|
||||
|
@ -342,7 +342,7 @@ class RoomListFragment @Inject constructor(
|
|||
// RoomSummaryController.Callback **************************************************************
|
||||
|
||||
override fun onRoomClicked(room: RoomSummary) {
|
||||
roomListViewModel.handle(RoomListActions.SelectRoom(room))
|
||||
roomListViewModel.handle(RoomListAction.SelectRoom(room))
|
||||
}
|
||||
|
||||
override fun onRoomLongClicked(room: RoomSummary): Boolean {
|
||||
|
@ -354,16 +354,16 @@ class RoomListFragment @Inject constructor(
|
|||
|
||||
override fun onAcceptRoomInvitation(room: RoomSummary) {
|
||||
notificationDrawerManager.clearMemberShipNotificationForRoom(room.roomId)
|
||||
roomListViewModel.handle(RoomListActions.AcceptInvitation(room))
|
||||
roomListViewModel.handle(RoomListAction.AcceptInvitation(room))
|
||||
}
|
||||
|
||||
override fun onRejectRoomInvitation(room: RoomSummary) {
|
||||
notificationDrawerManager.clearMemberShipNotificationForRoom(room.roomId)
|
||||
roomListViewModel.handle(RoomListActions.RejectInvitation(room))
|
||||
roomListViewModel.handle(RoomListAction.RejectInvitation(room))
|
||||
}
|
||||
|
||||
override fun onToggleRoomCategory(roomCategory: RoomCategory) {
|
||||
roomListViewModel.handle(RoomListActions.ToggleCategory(roomCategory))
|
||||
roomListViewModel.handle(RoomListAction.ToggleCategory(roomCategory))
|
||||
}
|
||||
|
||||
override fun createRoom(initialName: String) {
|
||||
|
|
|
@ -36,7 +36,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
|
|||
private val roomSummariesSource: DataSource<List<RoomSummary>>,
|
||||
private val alphabeticalRoomComparator: AlphabeticalRoomComparator,
|
||||
private val chronologicalRoomComparator: ChronologicalRoomComparator)
|
||||
: VectorViewModel<RoomListViewState, RoomListActions>(initialState) {
|
||||
: VectorViewModel<RoomListViewState, RoomListAction>(initialState) {
|
||||
|
||||
interface Factory {
|
||||
fun create(initialState: RoomListViewState): RoomListViewModel
|
||||
|
@ -61,30 +61,30 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
|
|||
observeRoomSummaries()
|
||||
}
|
||||
|
||||
override fun handle(action: RoomListActions) {
|
||||
override fun handle(action: RoomListAction) {
|
||||
when (action) {
|
||||
is RoomListActions.SelectRoom -> handleSelectRoom(action)
|
||||
is RoomListActions.ToggleCategory -> handleToggleCategory(action)
|
||||
is RoomListActions.AcceptInvitation -> handleAcceptInvitation(action)
|
||||
is RoomListActions.RejectInvitation -> handleRejectInvitation(action)
|
||||
is RoomListActions.FilterWith -> handleFilter(action)
|
||||
is RoomListActions.MarkAllRoomsRead -> handleMarkAllRoomsRead()
|
||||
is RoomListActions.LeaveRoom -> handleLeaveRoom(action)
|
||||
is RoomListActions.ChangeRoomNotificationState -> handleChangeNotificationMode(action)
|
||||
is RoomListAction.SelectRoom -> handleSelectRoom(action)
|
||||
is RoomListAction.ToggleCategory -> handleToggleCategory(action)
|
||||
is RoomListAction.AcceptInvitation -> handleAcceptInvitation(action)
|
||||
is RoomListAction.RejectInvitation -> handleRejectInvitation(action)
|
||||
is RoomListAction.FilterWith -> handleFilter(action)
|
||||
is RoomListAction.MarkAllRoomsRead -> handleMarkAllRoomsRead()
|
||||
is RoomListAction.LeaveRoom -> handleLeaveRoom(action)
|
||||
is RoomListAction.ChangeRoomNotificationState -> handleChangeNotificationMode(action)
|
||||
}
|
||||
}
|
||||
|
||||
// PRIVATE METHODS *****************************************************************************
|
||||
|
||||
private fun handleSelectRoom(action: RoomListActions.SelectRoom) {
|
||||
private fun handleSelectRoom(action: RoomListAction.SelectRoom) {
|
||||
_viewEvents.post(RoomListViewEvents.SelectRoom(action.roomSummary.roomId))
|
||||
}
|
||||
|
||||
private fun handleToggleCategory(action: RoomListActions.ToggleCategory) = setState {
|
||||
private fun handleToggleCategory(action: RoomListAction.ToggleCategory) = setState {
|
||||
this.toggle(action.category)
|
||||
}
|
||||
|
||||
private fun handleFilter(action: RoomListActions.FilterWith) {
|
||||
private fun handleFilter(action: RoomListAction.FilterWith) {
|
||||
setState {
|
||||
copy(
|
||||
roomFilter = action.filter
|
||||
|
@ -112,7 +112,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleAcceptInvitation(action: RoomListActions.AcceptInvitation) = withState { state ->
|
||||
private fun handleAcceptInvitation(action: RoomListAction.AcceptInvitation) = withState { state ->
|
||||
val roomId = action.roomSummary.roomId
|
||||
|
||||
if (state.joiningRoomsIds.contains(roomId) || state.rejectingRoomsIds.contains(roomId)) {
|
||||
|
@ -147,7 +147,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
|
|||
})
|
||||
}
|
||||
|
||||
private fun handleRejectInvitation(action: RoomListActions.RejectInvitation) = withState { state ->
|
||||
private fun handleRejectInvitation(action: RoomListAction.RejectInvitation) = withState { state ->
|
||||
val roomId = action.roomSummary.roomId
|
||||
|
||||
if (state.joiningRoomsIds.contains(roomId) || state.rejectingRoomsIds.contains(roomId)) {
|
||||
|
@ -193,7 +193,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
|
|||
?.let { session.markAllAsRead(it, object : MatrixCallback<Unit> {}) }
|
||||
}
|
||||
|
||||
private fun handleChangeNotificationMode(action: RoomListActions.ChangeRoomNotificationState) {
|
||||
private fun handleChangeNotificationMode(action: RoomListAction.ChangeRoomNotificationState) {
|
||||
session.getRoom(action.roomId)?.setRoomNotificationState(action.notificationState, object : MatrixCallback<Unit> {
|
||||
override fun onFailure(failure: Throwable) {
|
||||
_viewEvents.post(RoomListViewEvents.Failure(failure))
|
||||
|
@ -201,7 +201,7 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
|
|||
})
|
||||
}
|
||||
|
||||
private fun handleLeaveRoom(action: RoomListActions.LeaveRoom) {
|
||||
private fun handleLeaveRoom(action: RoomListAction.LeaveRoom) {
|
||||
session.getRoom(action.roomId)?.leave(object : MatrixCallback<Unit> {
|
||||
override fun onFailure(failure: Throwable) {
|
||||
_viewEvents.post(RoomListViewEvents.Failure(failure))
|
||||
|
|
|
@ -19,10 +19,10 @@ package im.vector.riotx.features.login
|
|||
import im.vector.matrix.android.api.auth.data.Credentials
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class LoginActions : VectorViewModelAction {
|
||||
data class UpdateHomeServer(val homeServerUrl: String) : LoginActions()
|
||||
data class Login(val login: String, val password: String) : LoginActions()
|
||||
data class SsoLoginSuccess(val credentials: Credentials) : LoginActions()
|
||||
data class NavigateTo(val target: LoginActivity.Navigation) : LoginActions()
|
||||
data class InitWith(val loginConfig: LoginConfig) : LoginActions()
|
||||
sealed class LoginAction : VectorViewModelAction {
|
||||
data class UpdateHomeServer(val homeServerUrl: String) : LoginAction()
|
||||
data class Login(val login: String, val password: String) : LoginAction()
|
||||
data class SsoLoginSuccess(val credentials: Credentials) : LoginAction()
|
||||
data class NavigateTo(val target: LoginActivity.Navigation) : LoginAction()
|
||||
data class InitWith(val loginConfig: LoginConfig) : LoginAction()
|
||||
}
|
|
@ -57,7 +57,7 @@ class LoginActivity : VectorBaseActivity() {
|
|||
// Get config extra
|
||||
val loginConfig = intent.getParcelableExtra<LoginConfig?>(EXTRA_CONFIG)
|
||||
if (loginConfig != null && isFirstCreation()) {
|
||||
loginViewModel.handle(LoginActions.InitWith(loginConfig))
|
||||
loginViewModel.handle(LoginAction.InitWith(loginConfig))
|
||||
}
|
||||
|
||||
loginViewModel.navigationLiveData.observeEvent(this) {
|
||||
|
|
|
@ -59,14 +59,14 @@ class LoginFragment @Inject constructor() : VectorBaseFragment() {
|
|||
homeServerField.focusChanges()
|
||||
.subscribe {
|
||||
if (!it) {
|
||||
viewModel.handle(LoginActions.UpdateHomeServer(homeServerField.text.toString()))
|
||||
viewModel.handle(LoginAction.UpdateHomeServer(homeServerField.text.toString()))
|
||||
}
|
||||
}
|
||||
.disposeOnDestroy()
|
||||
|
||||
homeServerField.setOnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
viewModel.handle(LoginActions.UpdateHomeServer(homeServerField.text.toString()))
|
||||
viewModel.handle(LoginAction.UpdateHomeServer(homeServerField.text.toString()))
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
return@setOnEditorActionListener false
|
||||
|
@ -78,7 +78,7 @@ class LoginFragment @Inject constructor() : VectorBaseFragment() {
|
|||
} else {
|
||||
homeServerField.setText(ServerUrlsRepository.getDefaultHomeServerUrl(requireContext()))
|
||||
}
|
||||
viewModel.handle(LoginActions.UpdateHomeServer(homeServerField.text.toString()))
|
||||
viewModel.handle(LoginAction.UpdateHomeServer(homeServerField.text.toString()))
|
||||
}
|
||||
|
||||
private fun setupNotice() {
|
||||
|
@ -93,7 +93,7 @@ class LoginFragment @Inject constructor() : VectorBaseFragment() {
|
|||
val login = loginField.text?.trim().toString()
|
||||
val password = passwordField.text?.trim().toString()
|
||||
|
||||
viewModel.handle(LoginActions.Login(login, password))
|
||||
viewModel.handle(LoginAction.Login(login, password))
|
||||
}
|
||||
|
||||
private fun setupAuthButton() {
|
||||
|
@ -114,7 +114,7 @@ class LoginFragment @Inject constructor() : VectorBaseFragment() {
|
|||
}
|
||||
|
||||
private fun openSso() {
|
||||
viewModel.handle(LoginActions.NavigateTo(LoginActivity.Navigation.OpenSsoLoginFallback))
|
||||
viewModel.handle(LoginAction.NavigateTo(LoginActivity.Navigation.OpenSsoLoginFallback))
|
||||
}
|
||||
|
||||
private fun setupPasswordReveal() {
|
||||
|
|
|
@ -143,7 +143,7 @@ class LoginSsoFallbackFragment @Inject constructor() : VectorBaseFragment(), OnB
|
|||
super.onReceivedError(view, errorCode, description, failingUrl)
|
||||
|
||||
// on error case, close this fragment
|
||||
viewModel.handle(LoginActions.NavigateTo(LoginActivity.Navigation.GoBack))
|
||||
viewModel.handle(LoginAction.NavigateTo(LoginActivity.Navigation.GoBack))
|
||||
}
|
||||
|
||||
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
||||
|
@ -253,7 +253,7 @@ class LoginSsoFallbackFragment @Inject constructor() : VectorBaseFragment(), OnB
|
|||
refreshToken = null
|
||||
)
|
||||
|
||||
viewModel.handle(LoginActions.SsoLoginSuccess(safeCredentials))
|
||||
viewModel.handle(LoginAction.SsoLoginSuccess(safeCredentials))
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
@ -278,7 +278,7 @@ class LoginSsoFallbackFragment @Inject constructor() : VectorBaseFragment(), OnB
|
|||
refreshToken = null
|
||||
)
|
||||
|
||||
viewModel.handle(LoginActions.SsoLoginSuccess(credentials))
|
||||
viewModel.handle(LoginAction.SsoLoginSuccess(credentials))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
|||
private val activeSessionHolder: ActiveSessionHolder,
|
||||
private val pushRuleTriggerListener: PushRuleTriggerListener,
|
||||
private val sessionListener: SessionListener)
|
||||
: VectorViewModel<LoginViewState, LoginActions>(initialState) {
|
||||
: VectorViewModel<LoginViewState, LoginAction>(initialState) {
|
||||
|
||||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
|
@ -67,21 +67,21 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
|||
private var homeServerConnectionConfig: HomeServerConnectionConfig? = null
|
||||
private var currentTask: Cancelable? = null
|
||||
|
||||
override fun handle(action: LoginActions) {
|
||||
override fun handle(action: LoginAction) {
|
||||
when (action) {
|
||||
is LoginActions.InitWith -> handleInitWith(action)
|
||||
is LoginActions.UpdateHomeServer -> handleUpdateHomeserver(action)
|
||||
is LoginActions.Login -> handleLogin(action)
|
||||
is LoginActions.SsoLoginSuccess -> handleSsoLoginSuccess(action)
|
||||
is LoginActions.NavigateTo -> handleNavigation(action)
|
||||
is LoginAction.InitWith -> handleInitWith(action)
|
||||
is LoginAction.UpdateHomeServer -> handleUpdateHomeserver(action)
|
||||
is LoginAction.Login -> handleLogin(action)
|
||||
is LoginAction.SsoLoginSuccess -> handleSsoLoginSuccess(action)
|
||||
is LoginAction.NavigateTo -> handleNavigation(action)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleInitWith(action: LoginActions.InitWith) {
|
||||
private fun handleInitWith(action: LoginAction.InitWith) {
|
||||
loginConfig = action.loginConfig
|
||||
}
|
||||
|
||||
private fun handleLogin(action: LoginActions.Login) {
|
||||
private fun handleLogin(action: LoginAction.Login) {
|
||||
val homeServerConnectionConfigFinal = homeServerConnectionConfig
|
||||
|
||||
if (homeServerConnectionConfigFinal == null) {
|
||||
|
@ -124,7 +124,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleSsoLoginSuccess(action: LoginActions.SsoLoginSuccess) {
|
||||
private fun handleSsoLoginSuccess(action: LoginAction.SsoLoginSuccess) {
|
||||
val homeServerConnectionConfigFinal = homeServerConnectionConfig
|
||||
|
||||
if (homeServerConnectionConfigFinal == null) {
|
||||
|
@ -137,7 +137,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleUpdateHomeserver(action: LoginActions.UpdateHomeServer) = withState { state ->
|
||||
private fun handleUpdateHomeserver(action: LoginAction.UpdateHomeServer) = withState { state ->
|
||||
|
||||
var newConfig: HomeServerConnectionConfig? = null
|
||||
Try {
|
||||
|
@ -197,7 +197,7 @@ class LoginViewModel @AssistedInject constructor(@Assisted initialState: LoginVi
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleNavigation(action: LoginActions.NavigateTo) {
|
||||
private fun handleNavigation(action: LoginAction.NavigateTo) {
|
||||
_navigationLiveData.postValue(LiveEvent(action.target))
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ class EmojiReactionPickerActivity : VectorBaseActivity(),
|
|||
tabLayout.isVisible = false
|
||||
emojiPickerWholeListFragmentContainer.isVisible = false
|
||||
emojiPickerFilteredListFragmentContainer.isVisible = true
|
||||
searchResultViewModel.handle(EmojiSearchActions.UpdateQuery(query))
|
||||
searchResultViewModel.handle(EmojiSearchAction.UpdateQuery(query))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@ package im.vector.riotx.features.reactions
|
|||
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class EmojiSearchActions : VectorViewModelAction {
|
||||
data class UpdateQuery(val queryString: String) : EmojiSearchActions()
|
||||
sealed class EmojiSearchAction : VectorViewModelAction {
|
||||
data class UpdateQuery(val queryString: String) : EmojiSearchAction()
|
||||
}
|
|
@ -26,15 +26,15 @@ data class EmojiSearchResultViewState(
|
|||
) : MvRxState
|
||||
|
||||
class EmojiSearchResultViewModel(val dataSource: EmojiDataSource, initialState: EmojiSearchResultViewState)
|
||||
: VectorViewModel<EmojiSearchResultViewState, EmojiSearchActions>(initialState) {
|
||||
: VectorViewModel<EmojiSearchResultViewState, EmojiSearchAction>(initialState) {
|
||||
|
||||
override fun handle(action: EmojiSearchActions) {
|
||||
override fun handle(action: EmojiSearchAction) {
|
||||
when (action) {
|
||||
is EmojiSearchActions.UpdateQuery -> updateQuery(action)
|
||||
is EmojiSearchAction.UpdateQuery -> updateQuery(action)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateQuery(action: EmojiSearchActions.UpdateQuery) {
|
||||
private fun updateQuery(action: EmojiSearchAction.UpdateQuery) {
|
||||
setState {
|
||||
copy(
|
||||
query = action.queryString,
|
||||
|
|
|
@ -66,7 +66,7 @@ class PublicRoomsFragment @Inject constructor(
|
|||
publicRoomsFilter.queryTextChanges()
|
||||
.debounce(500, TimeUnit.MILLISECONDS)
|
||||
.subscribeBy {
|
||||
viewModel.handle(RoomDirectoryActions.FilterWith(it.toString()))
|
||||
viewModel.handle(RoomDirectoryAction.FilterWith(it.toString()))
|
||||
}
|
||||
.disposeOnDestroy()
|
||||
|
||||
|
@ -130,11 +130,11 @@ class PublicRoomsFragment @Inject constructor(
|
|||
|
||||
override fun onPublicRoomJoin(publicRoom: PublicRoom) {
|
||||
Timber.v("PublicRoomJoinClicked: $publicRoom")
|
||||
viewModel.handle(RoomDirectoryActions.JoinRoom(publicRoom.roomId))
|
||||
viewModel.handle(RoomDirectoryAction.JoinRoom(publicRoom.roomId))
|
||||
}
|
||||
|
||||
override fun loadMore() {
|
||||
viewModel.handle(RoomDirectoryActions.LoadMore)
|
||||
viewModel.handle(RoomDirectoryAction.LoadMore)
|
||||
}
|
||||
|
||||
private var initialValueSet = false
|
||||
|
|
|
@ -19,9 +19,9 @@ package im.vector.riotx.features.roomdirectory
|
|||
import im.vector.matrix.android.api.session.room.model.thirdparty.RoomDirectoryData
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class RoomDirectoryActions : VectorViewModelAction {
|
||||
data class SetRoomDirectoryData(val roomDirectoryData: RoomDirectoryData) : RoomDirectoryActions()
|
||||
data class FilterWith(val filter: String) : RoomDirectoryActions()
|
||||
object LoadMore : RoomDirectoryActions()
|
||||
data class JoinRoom(val roomId: String) : RoomDirectoryActions()
|
||||
sealed class RoomDirectoryAction : VectorViewModelAction {
|
||||
data class SetRoomDirectoryData(val roomDirectoryData: RoomDirectoryData) : RoomDirectoryAction()
|
||||
data class FilterWith(val filter: String) : RoomDirectoryAction()
|
||||
object LoadMore : RoomDirectoryAction()
|
||||
data class JoinRoom(val roomId: String) : RoomDirectoryAction()
|
||||
}
|
|
@ -26,7 +26,7 @@ import im.vector.riotx.core.di.ScreenComponent
|
|||
import im.vector.riotx.core.extensions.addFragment
|
||||
import im.vector.riotx.core.extensions.addFragmentToBackstack
|
||||
import im.vector.riotx.core.platform.VectorBaseActivity
|
||||
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomActions
|
||||
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomAction
|
||||
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomFragment
|
||||
import im.vector.riotx.features.roomdirectory.createroom.CreateRoomViewModel
|
||||
import im.vector.riotx.features.roomdirectory.picker.RoomDirectoryPickerFragment
|
||||
|
@ -51,7 +51,7 @@ class RoomDirectoryActivity : VectorBaseActivity() {
|
|||
actionViewModel = ViewModelProviders.of(this, viewModelFactory).get(RoomDirectorySharedActionViewModel::class.java)
|
||||
|
||||
if (isFirstCreation()) {
|
||||
roomDirectoryViewModel.handle(RoomDirectoryActions.FilterWith(intent?.getStringExtra(INITIAL_FILTER) ?: ""))
|
||||
roomDirectoryViewModel.handle(RoomDirectoryAction.FilterWith(intent?.getStringExtra(INITIAL_FILTER) ?: ""))
|
||||
}
|
||||
|
||||
actionViewModel.observe()
|
||||
|
@ -67,7 +67,7 @@ class RoomDirectoryActivity : VectorBaseActivity() {
|
|||
|
||||
roomDirectoryViewModel.selectSubscribe(this, PublicRoomsViewState::currentFilter) { currentFilter ->
|
||||
// Transmit the filter to the createRoomViewModel
|
||||
createRoomViewModel.handle(CreateRoomActions.SetName(currentFilter))
|
||||
createRoomViewModel.handle(CreateRoomAction.SetName(currentFilter))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ private const val PUBLIC_ROOMS_LIMIT = 20
|
|||
|
||||
class RoomDirectoryViewModel @AssistedInject constructor(@Assisted initialState: PublicRoomsViewState,
|
||||
private val session: Session)
|
||||
: VectorViewModel<PublicRoomsViewState, RoomDirectoryActions>(initialState) {
|
||||
: VectorViewModel<PublicRoomsViewState, RoomDirectoryAction>(initialState) {
|
||||
|
||||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
|
@ -103,16 +103,16 @@ class RoomDirectoryViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
.disposeOnClear()
|
||||
}
|
||||
|
||||
override fun handle(action: RoomDirectoryActions) {
|
||||
override fun handle(action: RoomDirectoryAction) {
|
||||
when (action) {
|
||||
is RoomDirectoryActions.SetRoomDirectoryData -> setRoomDirectoryData(action)
|
||||
is RoomDirectoryActions.FilterWith -> filterWith(action)
|
||||
RoomDirectoryActions.LoadMore -> loadMore()
|
||||
is RoomDirectoryActions.JoinRoom -> joinRoom(action)
|
||||
is RoomDirectoryAction.SetRoomDirectoryData -> setRoomDirectoryData(action)
|
||||
is RoomDirectoryAction.FilterWith -> filterWith(action)
|
||||
RoomDirectoryAction.LoadMore -> loadMore()
|
||||
is RoomDirectoryAction.JoinRoom -> joinRoom(action)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setRoomDirectoryData(action: RoomDirectoryActions.SetRoomDirectoryData) {
|
||||
private fun setRoomDirectoryData(action: RoomDirectoryAction.SetRoomDirectoryData) {
|
||||
if (this.roomDirectoryData == action.roomDirectoryData) {
|
||||
return
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class RoomDirectoryViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
load("")
|
||||
}
|
||||
|
||||
private fun filterWith(action: RoomDirectoryActions.FilterWith) = withState { state ->
|
||||
private fun filterWith(action: RoomDirectoryAction.FilterWith) = withState { state ->
|
||||
if (state.currentFilter != action.filter) {
|
||||
currentTask?.cancel()
|
||||
|
||||
|
@ -201,7 +201,7 @@ class RoomDirectoryViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
})
|
||||
}
|
||||
|
||||
private fun joinRoom(action: RoomDirectoryActions.JoinRoom) = withState { state ->
|
||||
private fun joinRoom(action: RoomDirectoryAction.JoinRoom) = withState { state ->
|
||||
if (state.joiningRoomsIds.contains(action.roomId)) {
|
||||
// Request already sent, should not happen
|
||||
Timber.w("Try to join an already joining room. Should not happen")
|
||||
|
|
|
@ -18,9 +18,9 @@ package im.vector.riotx.features.roomdirectory.createroom
|
|||
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class CreateRoomActions : VectorViewModelAction {
|
||||
data class SetName(val name: String) : CreateRoomActions()
|
||||
data class SetIsPublic(val isPublic: Boolean) : CreateRoomActions()
|
||||
data class SetIsInRoomDirectory(val isInRoomDirectory: Boolean) : CreateRoomActions()
|
||||
object Create : CreateRoomActions()
|
||||
sealed class CreateRoomAction : VectorViewModelAction {
|
||||
data class SetName(val name: String) : CreateRoomAction()
|
||||
data class SetIsPublic(val isPublic: Boolean) : CreateRoomAction()
|
||||
data class SetIsInRoomDirectory(val isInRoomDirectory: Boolean) : CreateRoomAction()
|
||||
object Create : CreateRoomAction()
|
||||
}
|
|
@ -49,7 +49,7 @@ class CreateRoomActivity : VectorBaseActivity(), ToolbarConfigurable {
|
|||
override fun initUiAndData() {
|
||||
if (isFirstCreation()) {
|
||||
addFragment(R.id.simpleFragmentContainer, CreateRoomFragment::class.java)
|
||||
createRoomViewModel.handle(CreateRoomActions.SetName(intent?.getStringExtra(INITIAL_NAME) ?: ""))
|
||||
createRoomViewModel.handle(CreateRoomAction.SetName(intent?.getStringExtra(INITIAL_NAME) ?: ""))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C
|
|||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_create_room -> {
|
||||
viewModel.handle(CreateRoomActions.Create)
|
||||
viewModel.handle(CreateRoomAction.Create)
|
||||
true
|
||||
}
|
||||
else ->
|
||||
|
@ -71,20 +71,20 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C
|
|||
}
|
||||
|
||||
override fun onNameChange(newName: String) {
|
||||
viewModel.handle(CreateRoomActions.SetName(newName))
|
||||
viewModel.handle(CreateRoomAction.SetName(newName))
|
||||
}
|
||||
|
||||
override fun setIsPublic(isPublic: Boolean) {
|
||||
viewModel.handle(CreateRoomActions.SetIsPublic(isPublic))
|
||||
viewModel.handle(CreateRoomAction.SetIsPublic(isPublic))
|
||||
}
|
||||
|
||||
override fun setIsInRoomDirectory(isInRoomDirectory: Boolean) {
|
||||
viewModel.handle(CreateRoomActions.SetIsInRoomDirectory(isInRoomDirectory))
|
||||
viewModel.handle(CreateRoomAction.SetIsInRoomDirectory(isInRoomDirectory))
|
||||
}
|
||||
|
||||
override fun retry() {
|
||||
Timber.v("Retry")
|
||||
viewModel.handle(CreateRoomActions.Create)
|
||||
viewModel.handle(CreateRoomAction.Create)
|
||||
}
|
||||
|
||||
override fun invalidate() = withState(viewModel) { state ->
|
||||
|
|
|
@ -30,7 +30,7 @@ import im.vector.riotx.features.roomdirectory.RoomDirectoryActivity
|
|||
|
||||
class CreateRoomViewModel @AssistedInject constructor(@Assisted initialState: CreateRoomViewState,
|
||||
private val session: Session
|
||||
) : VectorViewModel<CreateRoomViewState, CreateRoomActions>(initialState) {
|
||||
) : VectorViewModel<CreateRoomViewState, CreateRoomAction>(initialState) {
|
||||
|
||||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
|
@ -51,20 +51,20 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted initialState: Cr
|
|||
}
|
||||
}
|
||||
|
||||
override fun handle(action: CreateRoomActions) {
|
||||
override fun handle(action: CreateRoomAction) {
|
||||
when (action) {
|
||||
is CreateRoomActions.SetName -> setName(action)
|
||||
is CreateRoomActions.SetIsPublic -> setIsPublic(action)
|
||||
is CreateRoomActions.SetIsInRoomDirectory -> setIsInRoomDirectory(action)
|
||||
is CreateRoomActions.Create -> doCreateRoom()
|
||||
is CreateRoomAction.SetName -> setName(action)
|
||||
is CreateRoomAction.SetIsPublic -> setIsPublic(action)
|
||||
is CreateRoomAction.SetIsInRoomDirectory -> setIsInRoomDirectory(action)
|
||||
is CreateRoomAction.Create -> doCreateRoom()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setName(action: CreateRoomActions.SetName) = setState { copy(roomName = action.name) }
|
||||
private fun setName(action: CreateRoomAction.SetName) = setState { copy(roomName = action.name) }
|
||||
|
||||
private fun setIsPublic(action: CreateRoomActions.SetIsPublic) = setState { copy(isPublic = action.isPublic) }
|
||||
private fun setIsPublic(action: CreateRoomAction.SetIsPublic) = setState { copy(isPublic = action.isPublic) }
|
||||
|
||||
private fun setIsInRoomDirectory(action: CreateRoomActions.SetIsInRoomDirectory) = setState { copy(isInRoomDirectory = action.isInRoomDirectory) }
|
||||
private fun setIsInRoomDirectory(action: CreateRoomAction.SetIsInRoomDirectory) = setState { copy(isInRoomDirectory = action.isInRoomDirectory) }
|
||||
|
||||
private fun doCreateRoom() = withState { state ->
|
||||
if (state.asyncCreateRoomRequest is Loading || state.asyncCreateRoomRequest is Success) {
|
||||
|
|
|
@ -18,6 +18,6 @@ package im.vector.riotx.features.roomdirectory.picker
|
|||
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class RoomDirectoryPickerActions : VectorViewModelAction {
|
||||
object Retry : RoomDirectoryPickerActions()
|
||||
sealed class RoomDirectoryPickerAction : VectorViewModelAction {
|
||||
object Retry : RoomDirectoryPickerAction()
|
||||
}
|
|
@ -27,7 +27,7 @@ import com.airbnb.mvrx.withState
|
|||
import im.vector.matrix.android.api.session.room.model.thirdparty.RoomDirectoryData
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.platform.VectorBaseFragment
|
||||
import im.vector.riotx.features.roomdirectory.RoomDirectoryActions
|
||||
import im.vector.riotx.features.roomdirectory.RoomDirectoryAction
|
||||
import im.vector.riotx.features.roomdirectory.RoomDirectorySharedAction
|
||||
import im.vector.riotx.features.roomdirectory.RoomDirectorySharedActionViewModel
|
||||
import im.vector.riotx.features.roomdirectory.RoomDirectoryViewModel
|
||||
|
@ -87,14 +87,14 @@ class RoomDirectoryPickerFragment @Inject constructor(val roomDirectoryPickerVie
|
|||
|
||||
override fun onRoomDirectoryClicked(roomDirectoryData: RoomDirectoryData) {
|
||||
Timber.v("onRoomDirectoryClicked: $roomDirectoryData")
|
||||
viewModel.handle(RoomDirectoryActions.SetRoomDirectoryData(roomDirectoryData))
|
||||
viewModel.handle(RoomDirectoryAction.SetRoomDirectoryData(roomDirectoryData))
|
||||
|
||||
actionViewModel.post(RoomDirectorySharedAction.Back)
|
||||
}
|
||||
|
||||
override fun retry() {
|
||||
Timber.v("Retry")
|
||||
pickerViewModel.handle(RoomDirectoryPickerActions.Retry)
|
||||
pickerViewModel.handle(RoomDirectoryPickerAction.Retry)
|
||||
}
|
||||
|
||||
override fun invalidate() = withState(pickerViewModel) { state ->
|
||||
|
|
|
@ -26,7 +26,7 @@ import im.vector.riotx.core.platform.VectorViewModel
|
|||
|
||||
class RoomDirectoryPickerViewModel @AssistedInject constructor(@Assisted initialState: RoomDirectoryPickerViewState,
|
||||
private val session: Session)
|
||||
: VectorViewModel<RoomDirectoryPickerViewState, RoomDirectoryPickerActions>(initialState) {
|
||||
: VectorViewModel<RoomDirectoryPickerViewState, RoomDirectoryPickerAction>(initialState) {
|
||||
|
||||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
|
@ -62,9 +62,9 @@ class RoomDirectoryPickerViewModel @AssistedInject constructor(@Assisted initial
|
|||
})
|
||||
}
|
||||
|
||||
override fun handle(action: RoomDirectoryPickerActions) {
|
||||
override fun handle(action: RoomDirectoryPickerAction) {
|
||||
when (action) {
|
||||
RoomDirectoryPickerActions.Retry -> load()
|
||||
RoomDirectoryPickerAction.Retry -> load()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ package im.vector.riotx.features.roomdirectory.roompreview
|
|||
|
||||
import im.vector.riotx.core.platform.VectorViewModelAction
|
||||
|
||||
sealed class RoomPreviewActions : VectorViewModelAction {
|
||||
object Join : RoomPreviewActions()
|
||||
sealed class RoomPreviewAction : VectorViewModelAction {
|
||||
object Join : RoomPreviewAction()
|
||||
}
|
|
@ -72,7 +72,7 @@ class RoomPreviewNoPreviewFragment @Inject constructor(
|
|||
|
||||
roomPreviewNoPreviewJoin.callback = object : ButtonStateView.Callback {
|
||||
override fun onButtonClicked() {
|
||||
roomPreviewViewModel.handle(RoomPreviewActions.Join)
|
||||
roomPreviewViewModel.handle(RoomPreviewAction.Join)
|
||||
}
|
||||
|
||||
override fun onRetryClicked() {
|
||||
|
|
|
@ -31,7 +31,7 @@ import timber.log.Timber
|
|||
|
||||
class RoomPreviewViewModel @AssistedInject constructor(@Assisted initialState: RoomPreviewViewState,
|
||||
private val session: Session)
|
||||
: VectorViewModel<RoomPreviewViewState, RoomPreviewActions>(initialState) {
|
||||
: VectorViewModel<RoomPreviewViewState, RoomPreviewAction>(initialState) {
|
||||
|
||||
@AssistedInject.Factory
|
||||
interface Factory {
|
||||
|
@ -77,9 +77,9 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted initialState: R
|
|||
.disposeOnClear()
|
||||
}
|
||||
|
||||
override fun handle(action: RoomPreviewActions) {
|
||||
override fun handle(action: RoomPreviewAction) {
|
||||
when (action) {
|
||||
RoomPreviewActions.Join -> joinRoom()
|
||||
RoomPreviewAction.Join -> joinRoom()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue