Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 118da536 authored by Moez Bhatti's avatar Moez Bhatti
Browse files

Fix crash when deleting conversation

parent 33b239d3
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -80,14 +80,18 @@ class ConversationInfoPresenter @Inject constructor(
        disposables += markUnarchived
        disposables += deleteConversations

        val partsObservable = messageRepo.getPartsForConversation(threadId)
                .asObservable()
                .filter { parts -> parts.isLoaded && parts.isValid}

        disposables += Observables
                .combineLatest(conversation, partsObservable) { conversation, parts ->
                .combineLatest(
                        conversation,
                        messageRepo.getPartsForConversation(threadId).asObservable()
                ) { conversation, parts ->
                    val data = mutableListOf<ConversationInfoItem>()

                    // If some data was deleted, this isn't the place to handle it
                    if (!conversation.isLoaded || !conversation.isValid || !parts.isLoaded || !parts.isValid) {
                        return@combineLatest
                    }

                    data += conversation.recipients.map(::ConversationInfoRecipient)
                    data += ConversationInfoItem.ConversationInfoSettings(
                            name = conversation.name,