forked from upstream-mirrors/quik
Update badge and shortcuts after pinning
This commit is contained in:
@@ -18,15 +18,22 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.interactor
|
package com.moez.QKSMS.interactor
|
||||||
|
|
||||||
|
import com.moez.QKSMS.manager.ShortcutManager
|
||||||
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 MarkPinned @Inject constructor(private val conversationRepo: ConversationRepository) : Interactor<List<Long>>() {
|
class MarkPinned @Inject constructor(
|
||||||
|
private val conversationRepo: ConversationRepository,
|
||||||
|
private val updateBadge: UpdateBadge,
|
||||||
|
private val shortcutManager: ShortcutManager
|
||||||
|
) : 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.markPinned(*threadIds) }
|
.doOnNext { threadIds -> conversationRepo.markPinned(*threadIds) }
|
||||||
|
.doOnNext { shortcutManager.updateShortcuts() } // Update shortcuts
|
||||||
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge and widget
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,15 +18,22 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.interactor
|
package com.moez.QKSMS.interactor
|
||||||
|
|
||||||
|
import com.moez.QKSMS.manager.ShortcutManager
|
||||||
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 MarkUnpinned @Inject constructor(private val conversationRepo: ConversationRepository) : Interactor<List<Long>>() {
|
class MarkUnpinned @Inject constructor(
|
||||||
|
private val conversationRepo: ConversationRepository,
|
||||||
|
private val updateBadge: UpdateBadge,
|
||||||
|
private val shortcutManager: ShortcutManager
|
||||||
|
) : 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.markUnpinned(*threadIds) }
|
.doOnNext { threadIds -> conversationRepo.markUnpinned(*threadIds) }
|
||||||
|
.doOnNext { shortcutManager.updateShortcuts() } // Update shortcuts
|
||||||
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge and widget
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,7 @@ class ReceiveSms @Inject constructor(
|
|||||||
.map { conversation -> conversation.id } // Map to the id because [delay] will put us on the wrong thread
|
.map { conversation -> conversation.id } // Map to the id because [delay] will put us on the wrong thread
|
||||||
.doOnNext { threadId -> notificationManager.update(threadId) } // Update the notification
|
.doOnNext { threadId -> notificationManager.update(threadId) } // Update the notification
|
||||||
.doOnNext { shortcutManager.updateShortcuts() } // Update shortcuts
|
.doOnNext { shortcutManager.updateShortcuts() } // Update shortcuts
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge and widget
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user