Ensure that MMS have unique keys

This commit is contained in:
Moez Bhatti
2018-01-05 00:09:45 -05:00
parent 20f83fccf9
commit 613e3096a2
5 changed files with 27 additions and 12 deletions
+6 -1
View File
@@ -18,16 +18,21 @@
*/
package interactor
import common.util.Keys
import common.util.SyncManager
import io.reactivex.Flowable
import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Inject
class FullSync @Inject constructor(private val syncManager: SyncManager) : Interactor<Unit, Long>() {
class FullSync @Inject constructor(
private val syncManager: SyncManager,
private val keys: Keys
) : Interactor<Unit, Long>() {
override fun buildObservable(params: Unit): Flowable<Long> {
return Flowable.just(System.currentTimeMillis())
.doOnNext { keys.reset() }
.doOnNext { syncManager.performSync(true) }
.map { startTime -> System.currentTimeMillis() - startTime }
.map { elapsed -> TimeUnit.MILLISECONDS.toSeconds(elapsed) }
@@ -36,7 +36,6 @@ open class PartialSync @Inject constructor(
return Flowable.just(System.currentTimeMillis())
.skipWhile { !permissions.hasSmsAndContacts() }
.doOnNext { syncManager.performSync() }
.doOnNext { keys.refresh() }
.map { startTime -> System.currentTimeMillis() - startTime }
.map { elapsed -> TimeUnit.MILLISECONDS.toSeconds(elapsed) }
.doOnNext { seconds -> Timber.v("Completed sync in $seconds seconds") }