Add Delete action for notification (#1275)

This commit is contained in:
Kend
2018-08-10 03:29:26 +08:00
committed by Moez Bhatti
parent c42fe0e4fa
commit b69327cb71
43 changed files with 98 additions and 0 deletions
@@ -18,6 +18,7 @@
*/
package com.moez.QKSMS.interactor
import com.moez.QKSMS.manager.NotificationManager
import com.moez.QKSMS.repository.ConversationRepository
import com.moez.QKSMS.repository.MessageRepository
import io.reactivex.Flowable
@@ -26,6 +27,7 @@ import javax.inject.Inject
class DeleteMessages @Inject constructor(
private val conversationRepo: ConversationRepository,
private val messageRepo: MessageRepository,
private val notificationManager: NotificationManager,
private val updateBadge: UpdateBadge
) : Interactor<DeleteMessages.Params>() {
@@ -35,6 +37,7 @@ class DeleteMessages @Inject constructor(
return Flowable.just(params.messageIds.toLongArray())
.doOnNext { messageIds -> messageRepo.deleteMessages(*messageIds) } // Delete the messages
.doOnNext { params.threadId?.let { conversationRepo.updateConversations(it) } } // Update the conversation
.doOnNext { params.threadId?.let { notificationManager.update(it) } }
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
}