Skip to content

Commit 82391aa

Browse files
author
Maxime NATUREL
committed
Replacing ViewEvent by a ViewState property
1 parent 221cb24 commit 82391aa

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewEvents.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,4 @@ sealed class RoomDetailViewEvents : VectorViewEvents {
8484
data class StartChatEffect(val type: ChatEffect) : RoomDetailViewEvents()
8585
object StopChatEffects : RoomDetailViewEvents()
8686
object RoomReplacementStarted : RoomDetailViewEvents()
87-
88-
data class ChangeLocationIndicator(val isVisible: Boolean) : RoomDetailViewEvents()
8987
}

vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewState.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ data class RoomDetailViewState(
7575
val switchToParentSpace: Boolean = false,
7676
val rootThreadEventId: String? = null,
7777
val threadNotificationBadgeState: ThreadNotificationBadgeState = ThreadNotificationBadgeState(),
78-
val typingUsers: List<SenderInfo>? = null
78+
val typingUsers: List<SenderInfo>? = null,
79+
val isSharingLiveLocation: Boolean = false,
7980
) : MavericksState {
8081

8182
constructor(args: TimelineArgs) : this(

vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ class TimelineFragment @Inject constructor(
498498
RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects()
499499
is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it)
500500
RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement()
501-
is RoomDetailViewEvents.ChangeLocationIndicator -> handleChangeLocationIndicator(it)
502501
}
503502
}
504503

@@ -663,10 +662,6 @@ class TimelineFragment @Inject constructor(
663662
)
664663
}
665664

666-
private fun handleChangeLocationIndicator(event: RoomDetailViewEvents.ChangeLocationIndicator) {
667-
views.locationLiveStatusIndicator.isVisible = event.isVisible
668-
}
669-
670665
private fun displayErrorMessage(error: RoomDetailViewEvents.Failure) {
671666
if (error.showInDialog) displayErrorDialog(error.throwable) else showErrorInSnackbar(error.throwable)
672667
}
@@ -1686,6 +1681,11 @@ class TimelineFragment @Inject constructor(
16861681
} else if (mainState.asyncInviter.complete) {
16871682
vectorBaseActivity.finish()
16881683
}
1684+
updateLiveLocationIndicator(mainState.isSharingLiveLocation)
1685+
}
1686+
1687+
private fun updateLiveLocationIndicator(isSharingLiveLocation: Boolean) {
1688+
views.locationLiveStatusIndicator.isVisible = isSharingLiveLocation
16891689
}
16901690

16911691
private fun FragmentTimelineBinding.hideComposerViews() {
@@ -1706,7 +1706,7 @@ class TimelineFragment @Inject constructor(
17061706

17071707
private fun renderToolbar(roomSummary: RoomSummary?) {
17081708
when {
1709-
isLocalRoom() -> {
1709+
isLocalRoom() -> {
17101710
views.includeRoomToolbar.roomToolbarContentView.isVisible = false
17111711
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
17121712
setupToolbar(views.roomToolbar)
@@ -1724,7 +1724,7 @@ class TimelineFragment @Inject constructor(
17241724
}
17251725
views.includeThreadToolbar.roomToolbarThreadTitleTextView.text = resources.getText(R.string.thread_timeline_title)
17261726
}
1727-
else -> {
1727+
else -> {
17281728
views.includeRoomToolbar.roomToolbarContentView.isVisible = true
17291729
views.includeThreadToolbar.roomToolbarThreadConstraintLayout.isVisible = false
17301730
if (roomSummary == null) {

vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,11 +1295,11 @@ class TimelineViewModel @AssistedInject constructor(
12951295
}
12961296

12971297
override fun onLocationServiceRunning() {
1298-
_viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = true))
1298+
setState { copy(isSharingLiveLocation = true) }
12991299
}
13001300

13011301
override fun onLocationServiceStopped() {
1302-
_viewEvents.post(RoomDetailViewEvents.ChangeLocationIndicator(isVisible = false))
1302+
setState { copy(isSharingLiveLocation = false) }
13031303
// Bind again in case user decides to share live location without leaving the room
13041304
locationSharingServiceConnection.bind(this)
13051305
}

0 commit comments

Comments
 (0)