Keep contacts in sync

Fixes #329
This commit is contained in:
Moez Bhatti
2019-11-24 15:30:25 -05:00
parent 25cff7e346
commit 13c8ba3e78
10 changed files with 27 additions and 75 deletions
@@ -21,7 +21,6 @@ package com.moez.QKSMS.interactor
import com.moez.QKSMS.repository.SyncRepository
import io.reactivex.Flowable
import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Inject
class SyncContacts @Inject constructor(private val syncManager: SyncRepository) : Interactor<Unit>() {
@@ -30,8 +29,7 @@ class SyncContacts @Inject constructor(private val syncManager: SyncRepository)
return Flowable.just(System.currentTimeMillis())
.doOnNext { syncManager.syncContacts() }
.map { startTime -> System.currentTimeMillis() - startTime }
.map { elapsed -> TimeUnit.MILLISECONDS.toSeconds(elapsed) }
.doOnNext { seconds -> Timber.v("Completed sync in $seconds seconds") }
.doOnNext { duration -> Timber.v("Completed sync in ${duration}ms") }
}
}
@@ -22,6 +22,6 @@ import io.reactivex.Observable
interface ContactAddedListener {
fun listen(address: String): Observable<*>
fun listen(): Observable<*>
}
}
@@ -25,7 +25,7 @@ import io.reactivex.Observable
interface SyncRepository {
sealed class SyncProgress {
class Idle : SyncProgress()
object Idle : SyncProgress()
data class Running(val max: Int, val progress: Int, val indeterminate: Boolean) : SyncProgress()
}
@@ -37,11 +37,4 @@ interface SyncRepository {
fun syncContacts()
/**
* Syncs a single contact to the Realm
*
* Return false if the contact couldn't be found
*/
fun syncContact(address: String): Boolean
}
}