forked from upstream-mirrors/quik
During partial sync, only open conversations more recent than the last sync
This commit is contained in:
@@ -26,10 +26,12 @@ class CursorToConversation @Inject constructor(private val contactsRepo: Contact
|
||||
val URI: Uri = Uri.parse("content://mms-sms/conversations?simple=true")
|
||||
val PROJECTION = arrayOf(
|
||||
Threads._ID,
|
||||
Threads.RECIPIENT_IDS)
|
||||
Threads.RECIPIENT_IDS,
|
||||
Threads.DATE)
|
||||
|
||||
val ID = 0
|
||||
val RECIPIENT_IDS = 1
|
||||
val DATE = 2
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,14 +22,12 @@ open class PartialSync @Inject constructor(
|
||||
|
||||
override fun buildObservable(params: Unit): Flowable<Long> {
|
||||
val contentResolver = context.contentResolver
|
||||
val conversationsCursor = contentResolver.query(CursorToConversation.URI, CursorToConversation.PROJECTION, null, null, "date desc")
|
||||
|
||||
var realm: Realm? = null
|
||||
|
||||
var lastSync = 0L
|
||||
var startTime = 0L
|
||||
|
||||
return Flowable.just(conversationsCursor)
|
||||
return Flowable.just(params)
|
||||
.doOnNext {
|
||||
startTime = System.currentTimeMillis()
|
||||
|
||||
@@ -42,6 +40,7 @@ open class PartialSync @Inject constructor(
|
||||
// Add a log entry for this sync
|
||||
realm?.insert(SyncLog())
|
||||
}
|
||||
.map { contentResolver.query(CursorToConversation.URI, CursorToConversation.PROJECTION, "date >= ?", arrayOf(lastSync.toString()), "date desc") }
|
||||
.flatMap { cursor -> cursor.asFlowable().map { cursorToConversation.map(it) } }
|
||||
.distinct { conversation -> conversation.id }
|
||||
.doOnNext { conversation -> realm?.insertOrUpdate(conversation) }
|
||||
|
||||
Reference in New Issue
Block a user