Rework: avoid shortcut to access ViewModel state.
This commit is contained in:
parent
b6deff8a0b
commit
3ed66d636b
@ -1224,12 +1224,12 @@ class TimelineFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSearchAction() {
|
private fun handleSearchAction() = withState(timelineViewModel) { state ->
|
||||||
navigator.openSearch(
|
navigator.openSearch(
|
||||||
context = requireContext(),
|
context = requireContext(),
|
||||||
roomId = timelineArgs.roomId,
|
roomId = timelineArgs.roomId,
|
||||||
roomDisplayName = timelineViewModel.getRoomSummary()?.displayName,
|
roomDisplayName = state.asyncRoomSummary()?.displayName,
|
||||||
roomAvatarUrl = timelineViewModel.getRoomSummary()?.avatarUrl
|
roomAvatarUrl = state.asyncRoomSummary()?.avatarUrl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2520,15 +2520,19 @@ class TimelineFragment :
|
|||||||
* Navigate to Threads timeline for the specified rootThreadEventId
|
* Navigate to Threads timeline for the specified rootThreadEventId
|
||||||
* using the ThreadsActivity.
|
* using the ThreadsActivity.
|
||||||
*/
|
*/
|
||||||
private fun navigateToThreadTimeline(rootThreadEventId: String, startsThread: Boolean = false, showKeyboard: Boolean = false) {
|
private fun navigateToThreadTimeline(
|
||||||
|
rootThreadEventId: String,
|
||||||
|
startsThread: Boolean = false,
|
||||||
|
showKeyboard: Boolean = false,
|
||||||
|
) = withState(timelineViewModel) { state ->
|
||||||
analyticsTracker.capture(Interaction.Name.MobileRoomThreadSummaryItem.toAnalyticsInteraction())
|
analyticsTracker.capture(Interaction.Name.MobileRoomThreadSummaryItem.toAnalyticsInteraction())
|
||||||
context?.let {
|
context?.let {
|
||||||
val roomThreadDetailArgs = ThreadTimelineArgs(
|
val roomThreadDetailArgs = ThreadTimelineArgs(
|
||||||
startsThread = startsThread,
|
startsThread = startsThread,
|
||||||
roomId = timelineArgs.roomId,
|
roomId = timelineArgs.roomId,
|
||||||
displayName = timelineViewModel.getRoomSummary()?.displayName,
|
displayName = state.asyncRoomSummary()?.displayName,
|
||||||
avatarUrl = timelineViewModel.getRoomSummary()?.avatarUrl,
|
avatarUrl = state.asyncRoomSummary()?.avatarUrl,
|
||||||
roomEncryptionTrustLevel = timelineViewModel.getRoomSummary()?.roomEncryptionTrustLevel,
|
roomEncryptionTrustLevel = state.asyncRoomSummary()?.roomEncryptionTrustLevel,
|
||||||
rootThreadEventId = rootThreadEventId,
|
rootThreadEventId = rootThreadEventId,
|
||||||
showKeyboard = showKeyboard
|
showKeyboard = showKeyboard
|
||||||
)
|
)
|
||||||
@ -2559,14 +2563,14 @@ class TimelineFragment :
|
|||||||
* Navigate to Threads list for the current room
|
* Navigate to Threads list for the current room
|
||||||
* using the ThreadsActivity.
|
* using the ThreadsActivity.
|
||||||
*/
|
*/
|
||||||
private fun navigateToThreadList() {
|
private fun navigateToThreadList() = withState(timelineViewModel) { state ->
|
||||||
analyticsTracker.capture(Interaction.Name.MobileRoomThreadListButton.toAnalyticsInteraction())
|
analyticsTracker.capture(Interaction.Name.MobileRoomThreadListButton.toAnalyticsInteraction())
|
||||||
context?.let {
|
context?.let {
|
||||||
val roomThreadDetailArgs = ThreadTimelineArgs(
|
val roomThreadDetailArgs = ThreadTimelineArgs(
|
||||||
roomId = timelineArgs.roomId,
|
roomId = timelineArgs.roomId,
|
||||||
displayName = timelineViewModel.getRoomSummary()?.displayName,
|
displayName = state.asyncRoomSummary()?.displayName,
|
||||||
roomEncryptionTrustLevel = timelineViewModel.getRoomSummary()?.roomEncryptionTrustLevel,
|
roomEncryptionTrustLevel = state.asyncRoomSummary()?.roomEncryptionTrustLevel,
|
||||||
avatarUrl = timelineViewModel.getRoomSummary()?.avatarUrl
|
avatarUrl = state.asyncRoomSummary()?.avatarUrl
|
||||||
)
|
)
|
||||||
navigator.openThreadList(it, roomThreadDetailArgs)
|
navigator.openThreadList(it, roomThreadDetailArgs)
|
||||||
}
|
}
|
||||||
|
@ -402,8 +402,6 @@ class TimelineViewModel @AssistedInject constructor(
|
|||||||
|
|
||||||
fun getOtherUserIds() = room.roomSummary()?.otherMemberIds
|
fun getOtherUserIds() = room.roomSummary()?.otherMemberIds
|
||||||
|
|
||||||
fun getRoomSummary() = room.roomSummary()
|
|
||||||
|
|
||||||
override fun handle(action: RoomDetailAction) {
|
override fun handle(action: RoomDetailAction) {
|
||||||
when (action) {
|
when (action) {
|
||||||
is RoomDetailAction.ComposerFocusChange -> handleComposerFocusChange(action)
|
is RoomDetailAction.ComposerFocusChange -> handleComposerFocusChange(action)
|
||||||
|
Loading…
Reference in New Issue
Block a user