#1233 - Dismiss notification when deleting conversation

This commit is contained in:
Moez Bhatti
2018-07-24 15:07:27 -04:00
parent dbbb7ffcdf
commit b2f5ccedf9
@@ -18,18 +18,21 @@
*/
package com.moez.QKSMS.interactor
import com.moez.QKSMS.manager.NotificationManager
import com.moez.QKSMS.repository.ConversationRepository
import io.reactivex.Flowable
import javax.inject.Inject
class DeleteConversations @Inject constructor(
private val conversationRepo: ConversationRepository,
private val notificationManager: NotificationManager,
private val updateBadge: UpdateBadge
) : Interactor<List<Long>>() {
override fun buildObservable(params: List<Long>): Flowable<*> {
return Flowable.just(params.toLongArray())
.doOnNext { threadIds -> conversationRepo.deleteConversations(*threadIds) }
.doOnNext { threadIds -> threadIds.forEach(notificationManager::update) }
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
}