Skip to content

Commit

Permalink
feat: clear orphaned events on navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Oct 11, 2023
1 parent e0279f3 commit 503cccf
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.asset.GetMessageAssetUseCase
import com.wire.kalium.logic.feature.asset.MessageAssetResult
import com.wire.kalium.logic.feature.asset.UpdateAssetMessageDownloadStatusUseCase
import com.wire.kalium.logic.feature.conversation.ClearUsersTypingEventsUseCase
import com.wire.kalium.logic.feature.conversation.GetConversationUnreadEventsCountUseCase
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
import com.wire.kalium.logic.feature.message.GetMessageByIdUseCase
Expand Down Expand Up @@ -83,7 +84,8 @@ class ConversationMessagesViewModel @Inject constructor(
private val toggleReaction: ToggleReactionUseCase,
private val resetSession: ResetSessionUseCase,
private val conversationAudioMessagePlayer: ConversationAudioMessagePlayer,
private val getConversationUnreadEventsCount: GetConversationUnreadEventsCountUseCase
private val getConversationUnreadEventsCount: GetConversationUnreadEventsCountUseCase,
private val clearUsersTypingEvents: ClearUsersTypingEventsUseCase
) : SavedStateViewModel(savedStateHandle) {

private val conversationNavArgs: ConversationNavArgs = savedStateHandle.navArgs()
Expand All @@ -97,11 +99,16 @@ class ConversationMessagesViewModel @Inject constructor(
val infoMessage = _infoMessage.asSharedFlow()

init {
clearOrphanedTypingEvents()
loadPaginatedMessages()
loadLastMessageInstant()
observeAudioPlayerState()
}

private fun clearOrphanedTypingEvents() {
viewModelScope.launch { clearUsersTypingEvents() }
}

private fun observeAudioPlayerState() {
viewModelScope.launch {
conversationAudioMessagePlayer.observableAudioMessagesState.collect {
Expand Down

0 comments on commit 503cccf

Please sign in to comment.