mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-16 12:00:03 +03:00
Jump to unread marker instead of first unread message (#8305)
This commit is contained in:
parent
29777f50fa
commit
da5a3eaad8
5 changed files with 9 additions and 6 deletions
1
changelog.d/8268.bugfix
Normal file
1
changelog.d/8268.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
The read marker is stuck in the past
|
|
@ -39,7 +39,7 @@ sealed class RoomDetailAction : VectorViewModelAction {
|
||||||
data class UndoReaction(val targetEventId: String, val reaction: String, val reason: 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 RedactAction(val targetEventId: String, val reason: String? = "") : RoomDetailAction()
|
||||||
data class UpdateQuickReactAction(val targetEventId: String, val selectedReaction: String, val add: Boolean) : 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 NavigateToEvent(val eventId: String, val highlight: Boolean, val isFirstUnreadEvent: Boolean = false) : RoomDetailAction()
|
||||||
object MarkAllAsRead : RoomDetailAction()
|
object MarkAllAsRead : RoomDetailAction()
|
||||||
data class DownloadOrOpen(val eventId: String, val senderId: String?, val messageFileContent: MessageWithAttachmentContent) : RoomDetailAction()
|
data class DownloadOrOpen(val eventId: String, val senderId: String?, val messageFileContent: MessageWithAttachmentContent) : RoomDetailAction()
|
||||||
object JoinAndOpenReplacementRoom : RoomDetailAction()
|
object JoinAndOpenReplacementRoom : RoomDetailAction()
|
||||||
|
|
|
@ -41,7 +41,7 @@ sealed class RoomDetailViewEvents : VectorViewEvents {
|
||||||
|
|
||||||
data class OpenRoom(val roomId: String, val closeCurrentRoom: Boolean = false) : RoomDetailViewEvents()
|
data class OpenRoom(val roomId: String, val closeCurrentRoom: Boolean = false) : RoomDetailViewEvents()
|
||||||
|
|
||||||
data class NavigateToEvent(val eventId: String) : RoomDetailViewEvents()
|
data class NavigateToEvent(val eventId: String, val isFirstUnreadEvent: Boolean) : RoomDetailViewEvents()
|
||||||
data class JoinJitsiConference(val widget: Widget, val withVideo: Boolean) : RoomDetailViewEvents()
|
data class JoinJitsiConference(val widget: Widget, val withVideo: Boolean) : RoomDetailViewEvents()
|
||||||
object LeaveJitsiConference : RoomDetailViewEvents()
|
object LeaveJitsiConference : RoomDetailViewEvents()
|
||||||
|
|
||||||
|
|
|
@ -748,7 +748,9 @@ class TimelineFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun navigateToEvent(action: RoomDetailViewEvents.NavigateToEvent) {
|
private fun navigateToEvent(action: RoomDetailViewEvents.NavigateToEvent) {
|
||||||
val scrollPosition = timelineEventController.searchPositionOfEvent(action.eventId)
|
val scrollPosition = timelineEventController.getPositionOfReadMarker().takeIf { action.isFirstUnreadEvent }
|
||||||
|
?: timelineEventController.searchPositionOfEvent(action.eventId)
|
||||||
|
|
||||||
if (scrollPosition == null) {
|
if (scrollPosition == null) {
|
||||||
scrollOnHighlightedEventCallback.scheduleScrollTo(action.eventId)
|
scrollOnHighlightedEventCallback.scheduleScrollTo(action.eventId)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1995,10 +1997,10 @@ class TimelineFragment :
|
||||||
|
|
||||||
private fun onJumpToReadMarkerClicked() = withState(timelineViewModel) {
|
private fun onJumpToReadMarkerClicked() = withState(timelineViewModel) {
|
||||||
if (it.unreadState is UnreadState.HasUnread) {
|
if (it.unreadState is UnreadState.HasUnread) {
|
||||||
timelineViewModel.handle(RoomDetailAction.NavigateToEvent(it.unreadState.firstUnreadEventId, false))
|
timelineViewModel.handle(RoomDetailAction.NavigateToEvent(it.unreadState.firstUnreadEventId, highlight = false, isFirstUnreadEvent = true))
|
||||||
}
|
}
|
||||||
if (it.unreadState is UnreadState.ReadMarkerNotLoaded) {
|
if (it.unreadState is UnreadState.ReadMarkerNotLoaded) {
|
||||||
timelineViewModel.handle(RoomDetailAction.NavigateToEvent(it.unreadState.readMarkerId, false))
|
timelineViewModel.handle(RoomDetailAction.NavigateToEvent(it.unreadState.readMarkerId, highlight = false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1033,7 +1033,7 @@ class TimelineViewModel @AssistedInject constructor(
|
||||||
if (action.highlight) {
|
if (action.highlight) {
|
||||||
setState { copy(highlightedEventId = targetEventId) }
|
setState { copy(highlightedEventId = targetEventId) }
|
||||||
}
|
}
|
||||||
_viewEvents.post(RoomDetailViewEvents.NavigateToEvent(targetEventId))
|
_viewEvents.post(RoomDetailViewEvents.NavigateToEvent(targetEventId, action.isFirstUnreadEvent))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleResendEvent(action: RoomDetailAction.ResendMessage) {
|
private fun handleResendEvent(action: RoomDetailAction.ResendMessage) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue