Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Removing timeout to be fixed in #791
Browse files Browse the repository at this point in the history
  • Loading branch information
Elise Richards committed Jul 16, 2019
1 parent 6fe2146 commit dc06456
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
17 changes: 9 additions & 8 deletions app/src/main/java/mozilla/lockbox/presenter/ItemListPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ItemListPresenter(
.map {
when (it) {
DataStore.SyncState.Syncing -> true
DataStore.SyncState.NotSyncing, DataStore.SyncState.TimedOut -> false
DataStore.SyncState.NotSyncing -> false
}
}
.subscribe { syncing ->
Expand All @@ -84,13 +84,14 @@ class ItemListPresenter(
}
.addTo(compositeDisposable)

dataStore.syncState
.filter { it == DataStore.SyncState.TimedOut }
.map { R.string.sync_timed_out }
.observeOn(AndroidSchedulers.mainThread())
.subscribe(view::showToastNotification)
.addTo(compositeDisposable)

/* timeout to be fixed in https://github.com/mozilla-lockwise/lockwise-android/issues/791
dataStore.syncState
.filter { it == DataStore.SyncState.TimedOut }
.map { R.string.sync_timed_out }
.observeOn(AndroidSchedulers.mainThread())
.subscribe(view::showToastNotification)
.addTo(compositeDisposable)
*/
Observables.combineLatest(dataStore.list, settingStore.itemListSortOrder)
.distinctUntilChanged()
.map { pair ->
Expand Down
17 changes: 13 additions & 4 deletions app/src/main/java/mozilla/lockbox/store/DataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ import mozilla.lockbox.extensions.filterByType
import mozilla.lockbox.flux.Dispatcher
import mozilla.lockbox.log
import mozilla.lockbox.model.SyncCredentials
import mozilla.lockbox.support.Consumable
import mozilla.lockbox.support.Constant
import mozilla.lockbox.support.Consumable
import mozilla.lockbox.support.DataStoreSupport
import mozilla.lockbox.support.FxASyncDataStoreSupport
import mozilla.lockbox.support.Optional
import mozilla.lockbox.support.TimingSupport
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
import kotlin.coroutines.CoroutineContext

@ExperimentalCoroutinesApi
Expand All @@ -55,7 +54,7 @@ open class DataStore(
}

enum class SyncState {
Syncing, NotSyncing, TimedOut
Syncing, NotSyncing
}

internal val compositeDisposable = CompositeDisposable()
Expand Down Expand Up @@ -241,6 +240,16 @@ open class DataStore(
// ideally, we don't sync unless we are connected to the network
syncStateSubject.accept(SyncState.Syncing)

backend.sync(support.syncConfig!!)
.asSingle(coroutineContext)
.timeout(Constant.App.syncTimeout, TimeUnit.SECONDS)
.doOnEvent { _, _ ->
syncStateSubject.accept(SyncState.NotSyncing)
}
.subscribe(this::updateList, this::pushError)
.addTo(compositeDisposable)

/* timeout to be fixed in https://github.com/mozilla-lockwise/lockwise-android/issues/791
backend.sync(support.syncConfig!!)
.asSingle(coroutineContext)
.timeout(Constant.App.syncTimeout, TimeUnit.SECONDS)
Expand All @@ -252,7 +261,7 @@ open class DataStore(
}
}
.subscribe(this::updateList, this::pushError)
.addTo(compositeDisposable)
.addTo(compositeDisposable) */
}

// item list management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,14 @@ open class ItemListPresenterTest {
syncStateStub.onNext(DataStore.SyncState.NotSyncing)
Assert.assertEquals(false, view.isLoading)
}

/* timeout to be fixed in https://github.com/mozilla-lockwise/lockwise-android/issues/791
@Test
fun `sync timeout indicator`() {
syncStateStub.onNext(DataStore.SyncState.TimedOut)
Assert.assertEquals(false, view.isLoading)
Assert.assertEquals(R.string.sync_timed_out, view.toastNotificationArgStrId)
}

*/
@Test
fun `item deleted toast`() {
val item = ServerPasswordTestHelper().item1
Expand Down
4 changes: 2 additions & 2 deletions app/src/test/java/mozilla/lockbox/store/DataStoreTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class DataStoreTest : DisposingTest() {
Assert.assertEquals(expectedSyncUnlockInfo.syncKey, support.syncConfig!!.syncKey)
Assert.assertEquals(expectedSyncUnlockInfo.tokenserverURL, support.syncConfig!!.tokenserverURL)
}

/* timeout to be fixed in https://github.com/mozilla-lockwise/lockwise-android/issues/791
@Test
fun testSync() {
val syncIterator = this.subject.syncState.blockingIterable().iterator()
Expand All @@ -222,7 +222,7 @@ class DataStoreTest : DisposingTest() {
Assert.assertEquals(DataStore.SyncState.Syncing, syncIterator.next())
Assert.assertEquals(DataStore.SyncState.TimedOut, syncIterator.next())
}

*/
@Test
fun testGet() {
val stateIterator = this.subject.state.blockingIterable().iterator()
Expand Down

0 comments on commit dc06456

Please sign in to comment.