Replacing ViewEvent by a ViewState property
This commit is contained in:
parent
221cb24de8
commit
82391aa281
|
@ -84,6 +84,4 @@ sealed class RoomDetailViewEvents : VectorViewEvents {
|
|||
data class StartChatEffect(val type: ChatEffect) : RoomDetailViewEvents()
|
||||
object StopChatEffects : RoomDetailViewEvents()
|
||||
object RoomReplacementStarted : RoomDetailViewEvents()
|
||||
|
||||
data class ChangeLocationIndicator(val isVisible: Boolean) : RoomDetailViewEvents()
|
||||
}
|
||||
|
|
|
@ -75,7 +75,8 @@ data class RoomDetailViewState(
|
|||
val switchToParentSpace: Boolean = false,
|
||||
val rootThreadEventId: String? = null,
|
||||
val threadNotificationBadgeState: ThreadNotificationBadgeState = ThreadNotificationBadgeState(),
|
||||
val typingUsers: List<SenderInfo>? = null
|
||||
val typingUsers: List<SenderInfo>? = null,
|
||||
val isSharingLiveLocation: Boolean = false,
|
||||
) : MavericksState {
|
||||
|
||||
constructor(args: TimelineArgs) : this(
|
||||
|
|
|
@ -498,7 +498,6 @@ class TimelineFragment @Inject constructor(
|
|||
RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects()
|
||||
is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it)
|
||||
RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement()
|
||||
is RoomDetailViewEvents.ChangeLocationIndicator -> handleChangeLocationIndicator(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -663,10 +662,6 @@ class TimelineFragment @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun handleChangeLocationIndicator(event: RoomDetailViewEvents.ChangeLocationIndicator) {
|
||||
views.locationLiveStatusIndicator.isVisible = event.isVisible
|
||||
}
|
||||
|
||||
private fun displayErrorMessage(error: RoomDetailViewEvents.Failure) {
|
||||
if (error.showInDialog) displayErrorDialog(error.throwable) else showErrorInSnackbar(error.throwable)
|
||||
}
|
||||
|
@ -1686,6 +1681,11 @@ class TimelineFragment @Inject constructor(
|
|||
} else if (mainState.asyncInviter.complete) {
|
||||
vectorBaseActivity.finish()
|
||||
}
|
||||
updateLiveLocationIndicator(mainState.isSharingLiveLocation)
|
||||
}
|
||||
|
||||
private fun updateLiveLocationIndicator(isSharingLiveLocation: Boolean) {
|
||||
views.locationLiveStatusIndicator.isVisible = isSharingLiveLocation
|
||||
}
|
||||
|
||||
private fun FragmentTimelineBinding.hideComposerViews() {
|
||||
|
@ -1706,7 +1706,7 @@ class TimelineFragment @Inject constructor(
|
|||
|
||||
private fun renderToolbar(roomSummary: RoomSummary?) {
|
||||
when {
|
||||
isLocalRoom() -> {
|
||||
isLocalRoom() -> {
|
||||
views.includeRoomToolbar.roomToolbarContentView.isVisible = false
|
||||
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
|
||||
setupToolbar(views.roomToolbar)
|
||||
|
@ -1724,7 +1724,7 @@ class TimelineFragment @Inject constructor(
|
|||
}
|
||||
views.includeThreadToolbar.roomToolbarThreadTitleTextView.text = resources.getText(R.string.thread_timeline_title)
|
||||
}
|
||||
else -> {
|
||||
else -> {
|
||||
views.includeRoomToolbar.roomToolbarContentView.isVisible = true
|
||||
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
|
||||
if (roomSummary == null) {
|
||||
|
|
|
@ -1295,11 +1295,11 @@ class TimelineViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
override fun onLocationServiceRunning() {
|
||||
_viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = true))
|
||||
setState { copy(isSharingLiveLocation = true) }
|
||||
}
|
||||
|
||||
override fun onLocationServiceStopped() {
|
||||
_viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = false))
|
||||
setState { copy(isSharingLiveLocation = false) }
|
||||
// Bind again in case user decides to share live location without leaving the room
|
||||
locationSharingServiceConnection.bind(this)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue