forked from upstream-mirrors/quik
Use latest message for lastSync timestamp
This commit is contained in:
@@ -64,14 +64,14 @@ class SyncManager @Inject constructor(
|
||||
realm.delete(SyncLog::class.java)
|
||||
}
|
||||
|
||||
val lastSync = realm.where(SyncLog::class.java)?.max("date")?.toLong() ?: 0
|
||||
val lastSync = realm.where(Message::class.java)?.max("date")?.toLong() ?: 0
|
||||
realm.insert(SyncLog())
|
||||
|
||||
// Sync conversations
|
||||
val conversationCursor = contentResolver.query(
|
||||
CursorToConversation.URI,
|
||||
CursorToConversation.PROJECTION,
|
||||
"date >= ?", arrayOf(lastSync.toString()),
|
||||
"date > ?", arrayOf(lastSync.toString()),
|
||||
"date desc")
|
||||
val conversations = conversationCursor.map { cursor -> cursorToConversation.map(cursor) }
|
||||
realm.insertOrUpdate(conversations)
|
||||
@@ -83,7 +83,7 @@ class SyncManager @Inject constructor(
|
||||
val messageColumns = CursorToMessage.MessageColumns(messageCursor)
|
||||
val messages = messageCursor.mapWhile(
|
||||
{ cursor -> cursorToMessage.map(Pair(cursor, messageColumns)) },
|
||||
{ message -> message.date >= lastSync })
|
||||
{ message -> message.date > lastSync })
|
||||
realm.insertOrUpdate(messages)
|
||||
messageCursor.close()
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package interactor
|
||||
|
||||
import common.util.Keys
|
||||
import common.util.Permissions
|
||||
import common.util.SyncManager
|
||||
import io.reactivex.Flowable
|
||||
@@ -28,8 +27,7 @@ import javax.inject.Inject
|
||||
|
||||
open class PartialSync @Inject constructor(
|
||||
private val syncManager: SyncManager,
|
||||
private val permissions: Permissions,
|
||||
private val keys: Keys
|
||||
private val permissions: Permissions
|
||||
) : Interactor<Unit, Long>() {
|
||||
|
||||
override fun buildObservable(params: Unit): Flowable<Long> {
|
||||
|
||||
Reference in New Issue
Block a user