@@ -40,7 +40,6 @@ import androidx.core.view.isInvisible
40
40
import androidx.core.view.isVisible
41
41
import androidx.lifecycle.Lifecycle
42
42
import androidx.lifecycle.lifecycleScope
43
- import com.airbnb.mvrx.args
44
43
import com.airbnb.mvrx.existingViewModel
45
44
import com.airbnb.mvrx.withState
46
45
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@@ -74,7 +73,6 @@ import im.vector.app.features.home.AvatarRenderer
74
73
import im.vector.app.features.home.room.detail.AutoCompleter
75
74
import im.vector.app.features.home.room.detail.RoomDetailAction
76
75
import im.vector.app.features.home.room.detail.TimelineViewModel
77
- import im.vector.app.features.home.room.detail.arguments.TimelineArgs
78
76
import im.vector.app.features.home.room.detail.composer.voice.VoiceMessageRecorderView
79
77
import im.vector.app.features.home.room.detail.timeline.action.MessageSharedActionViewModel
80
78
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
@@ -131,14 +129,14 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
131
129
@Inject lateinit var buildMeta: BuildMeta
132
130
@Inject lateinit var session: Session
133
131
134
- private val timelineArgs : TimelineArgs by args()
132
+ private val roomId : String get() = withState(timelineViewModel) { it.roomId }
135
133
136
134
private val autoCompleter: AutoCompleter by lazy {
137
- autoCompleterFactory.create(timelineArgs. roomId, isThreadTimeLine())
135
+ autoCompleterFactory.create(roomId, isThreadTimeLine())
138
136
}
139
137
140
138
private val pillsPostProcessor by lazy {
141
- pillsPostProcessorFactory.create(timelineArgs. roomId)
139
+ pillsPostProcessorFactory.create(roomId)
142
140
}
143
141
144
142
private val emojiPopup: EmojiPopup by lifecycleAwareLazy {
@@ -267,7 +265,8 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
267
265
268
266
views.composerLayout.views.composerEmojiButton.isVisible = vectorPreferences.showEmojiKeyboard()
269
267
270
- if (isThreadTimeLine() && timelineArgs.threadTimelineArgs?.showKeyboard == true ) {
268
+ val showKeyboard = withState(timelineViewModel) { it.showKeyboardWhenPresented }
269
+ if (isThreadTimeLine() && showKeyboard) {
271
270
// Show keyboard when the user started a thread
272
271
views.composerLayout.views.composerEditText.showKeyboard(andRequestFocus = true )
273
272
}
@@ -555,7 +554,7 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
555
554
views.composerLayout.setTextIfDifferent(" " )
556
555
when (parsedCommand) {
557
556
is ParsedCommand .DevTools -> {
558
- navigator.openDevTools(requireContext(), timelineArgs. roomId)
557
+ navigator.openDevTools(requireContext(), roomId)
559
558
}
560
559
is ParsedCommand .SetMarkdown -> {
561
560
showSnackWithMessage(getString(if (parsedCommand.enable) R .string.markdown_has_been_enabled else R .string.markdown_has_been_disabled))
@@ -578,12 +577,13 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
578
577
579
578
private fun handleShowRoomUpgradeDialog (roomDetailViewEvents : MessageComposerViewEvents .ShowRoomUpgradeDialog ) {
580
579
val tag = MigrateRoomBottomSheet ::javaClass.name
581
- MigrateRoomBottomSheet .newInstance(timelineArgs.roomId, roomDetailViewEvents.newVersion)
580
+ val roomId = withState(timelineViewModel) { it.roomId }
581
+ MigrateRoomBottomSheet .newInstance(roomId, roomDetailViewEvents.newVersion)
582
582
.show(parentFragmentManager, tag)
583
583
}
584
584
585
585
private fun openRoomMemberProfile (userId : String ) {
586
- navigator.openRoomMemberProfile(userId = userId, roomId = timelineArgs. roomId, context = requireActivity())
586
+ navigator.openRoomMemberProfile(userId = userId, roomId = roomId, context = requireActivity())
587
587
}
588
588
589
589
private val contentAttachmentActivityResultLauncher = registerStartForActivityResult { activityResult ->
@@ -598,12 +598,12 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
598
598
/* *
599
599
* Returns the root thread event if we are in a thread room, otherwise returns null.
600
600
*/
601
- fun getRootThreadEventId (): String? = timelineArgs.threadTimelineArgs?. rootThreadEventId
601
+ fun getRootThreadEventId (): String? = withState(timelineViewModel) { it. rootThreadEventId }
602
602
603
603
/* *
604
604
* Returns true if the current room is a Thread room, false otherwise.
605
605
*/
606
- private fun isThreadTimeLine (): Boolean = timelineArgs.threadTimelineArgs?.rootThreadEventId != null
606
+ private fun isThreadTimeLine (): Boolean = withState(timelineViewModel) { it.isThreadTimeline() }
607
607
608
608
609
609
// AttachmentsHelper.Callback
@@ -656,12 +656,12 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
656
656
AttachmentTypeSelectorView .Type .GALLERY -> attachmentsHelper.selectGallery(attachmentMediaActivityResultLauncher)
657
657
AttachmentTypeSelectorView .Type .CONTACT -> attachmentsHelper.selectContact(attachmentContactActivityResultLauncher)
658
658
AttachmentTypeSelectorView .Type .STICKER -> timelineViewModel.handle(RoomDetailAction .SelectStickerAttachment )
659
- AttachmentTypeSelectorView .Type .POLL -> navigator.openCreatePoll(requireContext(), timelineArgs. roomId, null , PollMode .CREATE )
659
+ AttachmentTypeSelectorView .Type .POLL -> navigator.openCreatePoll(requireContext(), roomId, null , PollMode .CREATE )
660
660
AttachmentTypeSelectorView .Type .LOCATION -> {
661
661
navigator
662
662
.openLocationSharing(
663
663
context = requireContext(),
664
- roomId = timelineArgs. roomId,
664
+ roomId = roomId,
665
665
mode = LocationSharingMode .STATIC_SHARING ,
666
666
initialLocationData = null ,
667
667
locationOwnerId = session.myUserId
@@ -716,7 +716,7 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
716
716
}
717
717
718
718
private fun handleShareData () {
719
- when (val sharedData = timelineArgs .sharedData) {
719
+ when (val sharedData = withState(timelineViewModel) { it .sharedData } ) {
720
720
is SharedData .Text -> {
721
721
messageComposerViewModel.handle(MessageComposerAction .OnTextChanged (sharedData.text))
722
722
messageComposerViewModel.handle(MessageComposerAction .EnterRegularMode (fromSharing = true ))
0 commit comments