forked from upstream-mirrors/quik
Merge pull request #418 from gavine99/mesages-seen-read-congruence
maintain setting messages seen and read congruence with native provider db
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -32,9 +32,9 @@ class CancelDelayedMessage @Inject constructor(
|
|||||||
|
|
||||||
override fun buildObservable(params: Params): Flowable<*> {
|
override fun buildObservable(params: Params): Flowable<*> {
|
||||||
return Flowable.just(Unit)
|
return Flowable.just(Unit)
|
||||||
.doOnNext { messageRepo.cancelDelayedSms(params.messageId) }
|
.doOnNext { messageRepo.cancelDelayedSms(params.messageId) }
|
||||||
.doOnNext { messageRepo.deleteMessages(params.messageId) }
|
.doOnNext { messageRepo.deleteMessages(listOf(params.messageId)) }
|
||||||
.doOnNext { conversationRepo.updateConversations(params.threadId) } // Update the conversation
|
.doOnNext { conversationRepo.updateConversations(params.threadId) } // Update the conversation
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ class DeleteMessages @Inject constructor(
|
|||||||
data class Params(val messageIds: List<Long>, val threadId: Long)
|
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)
|
||||||
.doOnNext { messageIds -> messageRepo.deleteMessages(*messageIds) } // Delete the messages
|
.doOnNext { messageIds -> messageRepo.deleteMessages(messageIds) } // Delete the messages
|
||||||
.doOnNext { conversationRepo.updateConversations(params.threadId) } // Update the conversation
|
.doOnNext { conversationRepo.updateConversations(params.threadId) } // Update the conversation
|
||||||
.doOnNext { notificationManager.update(params.threadId) }
|
.doOnNext { notificationManager.update(params.threadId) }
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,10 +30,10 @@ class MarkRead @Inject constructor(
|
|||||||
) : 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)
|
||||||
.doOnNext { threadIds -> messageRepo.markRead(*threadIds) }
|
.doOnNext { threadIds -> messageRepo.markRead(threadIds) }
|
||||||
.doOnNext { threadIds -> threadIds.forEach(notificationManager::update) }
|
.doOnNext { threadIds -> threadIds.forEach(notificationManager::update) }
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,9 +28,9 @@ class MarkUnread @Inject constructor(
|
|||||||
) : 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)
|
||||||
.doOnNext { threadId -> messageRepo.markUnread(*threadId) }
|
.doOnNext { threadIds -> messageRepo.markUnread(threadIds) }
|
||||||
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
.flatMap { updateBadge.buildObservable(Unit) } // Update the badge
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ class ReceiveMms @Inject constructor(
|
|||||||
// TODO: Ideally this is done when we're saving the MMS to ContentResolver
|
// TODO: Ideally this is done when we're saving the MMS to ContentResolver
|
||||||
// This change can be made once we move the MMS storing code to the Data module
|
// This change can be made once we move the MMS storing code to the Data module
|
||||||
if (activeConversationManager.getActiveConversation() == message.threadId) {
|
if (activeConversationManager.getActiveConversation() == message.threadId) {
|
||||||
messageRepo.markRead(message.threadId)
|
messageRepo.markRead(listOf(message.threadId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.mapNotNull { message ->
|
.mapNotNull { message ->
|
||||||
@@ -62,13 +62,13 @@ class ReceiveMms @Inject constructor(
|
|||||||
Timber.v("block=$action, drop=$shouldDrop")
|
Timber.v("block=$action, drop=$shouldDrop")
|
||||||
|
|
||||||
if (action is BlockingClient.Action.Block && shouldDrop) {
|
if (action is BlockingClient.Action.Block && shouldDrop) {
|
||||||
messageRepo.deleteMessages(message.id)
|
messageRepo.deleteMessages(listOf(message.id))
|
||||||
return@mapNotNull null
|
return@mapNotNull null
|
||||||
}
|
}
|
||||||
|
|
||||||
when (action) {
|
when (action) {
|
||||||
is BlockingClient.Action.Block -> {
|
is BlockingClient.Action.Block -> {
|
||||||
messageRepo.markRead(message.threadId)
|
messageRepo.markRead(listOf(message.threadId))
|
||||||
conversationRepo.markBlocked(listOf(message.threadId), prefs.blockingManager.get(), action.reason)
|
conversationRepo.markBlocked(listOf(message.threadId), prefs.blockingManager.get(), action.reason)
|
||||||
}
|
}
|
||||||
is BlockingClient.Action.Unblock -> conversationRepo.markUnblocked(message.threadId)
|
is BlockingClient.Action.Unblock -> conversationRepo.markUnblocked(message.threadId)
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ class ReceiveSms @Inject constructor(
|
|||||||
((action is BlockingClient.Action.Block) && prefs.drop.get()) -> {
|
((action is BlockingClient.Action.Block) && prefs.drop.get()) -> {
|
||||||
// blocked and 'drop blocked.' remove from db and don't continue
|
// blocked and 'drop blocked.' remove from db and don't continue
|
||||||
Timber.v("address is blocked and drop blocked is on. dropped")
|
Timber.v("address is blocked and drop blocked is on. dropped")
|
||||||
messageRepo.deleteMessages(it.id)
|
messageRepo.deleteMessages(listOf(it.id))
|
||||||
return@mapNotNull null
|
return@mapNotNull null
|
||||||
}
|
}
|
||||||
action is BlockingClient.Action.Block -> {
|
action is BlockingClient.Action.Block -> {
|
||||||
// blocked
|
// blocked
|
||||||
Timber.v("address is blocked")
|
Timber.v("address is blocked")
|
||||||
messageRepo.markRead(it.threadId)
|
messageRepo.markRead(listOf(it.threadId))
|
||||||
conversationRepo.markBlocked(
|
conversationRepo.markBlocked(
|
||||||
listOf(it.threadId),
|
listOf(it.threadId),
|
||||||
prefs.blockingManager.get(),
|
prefs.blockingManager.get(),
|
||||||
|
|||||||
@@ -57,20 +57,20 @@ interface MessageRepository {
|
|||||||
*/
|
*/
|
||||||
fun getUnreadMessages(threadId: Long): RealmResults<Message>
|
fun getUnreadMessages(threadId: Long): RealmResults<Message>
|
||||||
|
|
||||||
fun markAllSeen()
|
fun markAllSeen(): Int
|
||||||
|
|
||||||
fun markSeen(threadId: Long)
|
fun markSeen(threadId: Long): Int
|
||||||
|
|
||||||
fun markRead(vararg threadIds: Long)
|
fun markRead(threadIds: Collection<Long>): Int
|
||||||
|
|
||||||
fun markUnread(vararg threadIds: Long)
|
fun markUnread(threadIds: Collection<Long>): Int
|
||||||
|
|
||||||
fun sendMessage(
|
fun sendMessage(
|
||||||
subId: Int,
|
subId: Int,
|
||||||
threadId: Long,
|
threadId: Long,
|
||||||
addresses: List<String>,
|
addresses: Collection<String>,
|
||||||
body: String,
|
body: String,
|
||||||
attachments: List<Attachment>,
|
attachments: Collection<Attachment>,
|
||||||
delay: Int = 0
|
delay: Int = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ interface MessageRepository {
|
|||||||
|
|
||||||
fun markDeliveryFailed(id: Long, resultCode: Int)
|
fun markDeliveryFailed(id: Long, resultCode: Int)
|
||||||
|
|
||||||
fun deleteMessages(vararg messageIds: Long)
|
fun deleteMessages(messageIds: Collection<Long>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of messages older than [maxAgeDays] per conversation
|
* Returns the number of messages older than [maxAgeDays] per conversation
|
||||||
|
|||||||
Reference in New Issue
Block a user