forked from upstream-mirrors/quik
#1233 - Dismiss notification when deleting conversation
This commit is contained in:
@@ -18,18 +18,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.interactor
|
package com.moez.QKSMS.interactor
|
||||||
|
|
||||||
|
import com.moez.QKSMS.manager.NotificationManager
|
||||||
import com.moez.QKSMS.repository.ConversationRepository
|
import com.moez.QKSMS.repository.ConversationRepository
|
||||||
import io.reactivex.Flowable
|
import io.reactivex.Flowable
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class DeleteConversations @Inject constructor(
|
class DeleteConversations @Inject constructor(
|
||||||
private val conversationRepo: ConversationRepository,
|
private val conversationRepo: ConversationRepository,
|
||||||
|
private val notificationManager: NotificationManager,
|
||||||
private val updateBadge: UpdateBadge
|
private val updateBadge: UpdateBadge
|
||||||
) : Interactor<List<Long>>() {
|
) : Interactor<List<Long>>() {
|
||||||
|
|
||||||
override fun buildObservable(params: List<Long>): Flowable<*> {
|
override fun buildObservable(params: List<Long>): Flowable<*> {
|
||||||
return Flowable.just(params.toLongArray())
|
return Flowable.just(params.toLongArray())
|
||||||
.doOnNext { threadIds -> conversationRepo.deleteConversations(*threadIds) }
|
.doOnNext { threadIds -> conversationRepo.deleteConversations(*threadIds) }
|
||||||
|
.doOnNext { threadIds -> threadIds.forEach(notificationManager::update) }
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user