Ensure Mark as fully read is not invoked several times.

This commit is contained in:
Benoit Marty 2026-04-08 17:15:04 +02:00
parent c7d4c13efa
commit 4add14da84

View file

@ -250,8 +250,8 @@ class MessagesPresenter(
is MessagesEvent.OnUserClicked -> { is MessagesEvent.OnUserClicked -> {
roomMemberModerationState.eventSink(RoomMemberModerationEvents.ShowActionsForUser(event.user)) roomMemberModerationState.eventSink(RoomMemberModerationEvents.ShowActionsForUser(event.user))
} }
is MessagesEvent.MarkAsFullyReadAndExit -> coroutineScope.launch { is MessagesEvent.MarkAsFullyReadAndExit -> if (!markingAsReadAndExiting.getAndSet(true)) {
if (!markingAsReadAndExiting.getAndSet(true)) { coroutineScope.launch {
val latestEventId = room.liveTimeline.getLatestEventId().getOrElse { val latestEventId = room.liveTimeline.getLatestEventId().getOrElse {
Timber.w(it, "Failed to get latest event id to mark as fully read") Timber.w(it, "Failed to get latest event id to mark as fully read")
navigator.close() navigator.close()
@ -263,7 +263,6 @@ class MessagesPresenter(
} }
} }
navigator.close() navigator.close()
markingAsReadAndExiting.set(false)
} }
} }
} }