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

Commit 83c484d3 authored by Moez Bhatti's avatar Moez Bhatti
Browse files

Don't make threadId for DeleteMessages optional

parent e4f16b4d
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -31,15 +31,13 @@ class DeleteMessages @Inject constructor(
    private val updateBadge: UpdateBadge
    private val updateBadge: UpdateBadge
) : Interactor<DeleteMessages.Params>() {
) : Interactor<DeleteMessages.Params>() {


    data class Params(val messageIds: List<Long>, val threadId: Long? = null)
    data class Params(val messageIds: List<Long>, val threadId: Long)


    override fun buildObservable(params: Params): Flowable<*> {
    override fun buildObservable(params: Params): Flowable<*> {
        return Flowable.just(params.messageIds.toLongArray())
        return Flowable.just(params.messageIds.toLongArray())
                .doOnNext { messageIds -> messageRepo.deleteMessages(*messageIds) } // Delete the messages
                .doOnNext { messageIds -> messageRepo.deleteMessages(*messageIds) } // Delete the messages
                .doOnNext {
                .doOnNext { conversationRepo.updateConversations(params.threadId) } // Update the conversation
                    params.threadId?.let { conversationRepo.updateConversations(it) } // Update the conversation
                .doOnNext { notificationManager.update(params.threadId) }
                }
                .doOnNext { params.threadId?.let { notificationManager.update(it) } }
                .flatMap { updateBadge.buildObservable(Unit) } // Update the badge
                .flatMap { updateBadge.buildObservable(Unit) } // Update the badge
    }
    }