Skip to content
This repository was archived by the owner on Apr 17, 2021. It is now read-only.

Commit d19dd87

Browse files
committedMay 28, 2019
Issue #2325: Remove PocketRepoCache; add comment explaining why it's not necessary.
1 parent 5f25a63 commit d19dd87

File tree

7 files changed

+10
-139
lines changed

7 files changed

+10
-139
lines changed
 

‎app/src/main/java/org/mozilla/tv/firefox/architecture/ViewModelFactory.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ViewModelFactory(
3939
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
4040
return when (modelClass) {
4141
PocketViewModel::class.java -> PocketViewModel(
42-
serviceLocator.pocketRepoCache
42+
serviceLocator.pocketRepo
4343
) as T
4444

4545
ToolbarViewModel::class.java -> ToolbarViewModel(

‎app/src/main/java/org/mozilla/tv/firefox/pocket/PocketRepoCache.kt

-41
This file was deleted.

‎app/src/main/java/org/mozilla/tv/firefox/pocket/PocketVideoRepo.kt

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ open class PocketVideoRepo(
2929
.observeOn(AndroidSchedulers.mainThread())
3030
.distinctUntilChanged() // avoid churn because we may retrieve similar results in onStart.
3131

32+
/**
33+
* Gets the latest Pocket videos from the store and pushes it to the UI. This is intentionally
34+
* not reactive because a reactive update model might replace the content when the user is looking
35+
* at it. This method is expected to be called when the user is not looking at the content (e.g. in onStart).
36+
*/
3237
@UiThread // not sure if this annotation is necessary anymore.
3338
fun updatePocketFromStore() {
3439
// If we have no API key, this will always be the state: there is nothing to do. In theory, now that we

‎app/src/main/java/org/mozilla/tv/firefox/pocket/PocketViewModel.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const val POCKET_VIDEO_COUNT = 20
2323
* view should not have to perform any transformations on this data).
2424
*/
2525
class PocketViewModel(
26-
pocketRepoCache: PocketRepoCache
26+
pocketRepo: PocketVideoRepo
2727
) : ViewModel() {
2828

2929
sealed class State {
@@ -47,8 +47,7 @@ class PocketViewModel(
4747
}
4848
}
4949

50-
// #2297: the PocketRepoCache is broken and will not stop videos from updating when the user is looking at them.
51-
val state: Observable<State> = pocketRepoCache.feedState
50+
val state: Observable<State> = pocketRepo.feedState
5251
.map { repoState ->
5352
when (repoState) {
5453
is PocketVideoRepo.FeedState.LoadComplete -> State.Feed(repoState.videos)

‎app/src/main/java/org/mozilla/tv/firefox/utils/ServiceLocator.kt

-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import org.mozilla.tv.firefox.channels.pinnedtile.PinnedTileImageUtilWrapper
2727
import org.mozilla.tv.firefox.channels.pinnedtile.PinnedTileRepo
2828
import org.mozilla.tv.firefox.pocket.PocketEndpointRaw
2929
import org.mozilla.tv.firefox.pocket.PocketVideoFetchScheduler
30-
import org.mozilla.tv.firefox.pocket.PocketRepoCache
3130
import org.mozilla.tv.firefox.pocket.PocketVideoParser
3231
import org.mozilla.tv.firefox.pocket.PocketVideoRepo
3332
import org.mozilla.tv.firefox.pocket.PocketVideoStore
@@ -79,7 +78,6 @@ open class ServiceLocator(val app: Application) {
7978
val fretboardProvider: FretboardProvider by lazy { FretboardProvider(app) }
8079
val experimentsProvider by lazy { ExperimentsProvider(fretboardProvider.fretboard, app) }
8180
val turboMode: TurboMode by lazy { TurboMode(app) }
82-
val pocketRepoCache by lazy { PocketRepoCache(pocketRepo) }
8381
val viewModelFactory by lazy { ViewModelFactory(this, app) }
8482
val screenController by lazy { ScreenController(sessionRepo) }
8583
val engineViewCache by lazy { EngineViewCache(sessionRepo) }

‎app/src/test/java/org/mozilla/tv/firefox/pocket/PocketRepoCacheTest.kt

-85
This file was deleted.

‎app/src/test/java/org/mozilla/tv/firefox/pocket/PocketViewModelTest.kt

+2-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
package org.mozilla.tv.firefox.pocket
66

7-
import io.reactivex.Observable
87
import io.reactivex.observers.TestObserver
98
import io.reactivex.subjects.PublishSubject
109
import io.reactivex.subjects.Subject
@@ -27,13 +26,9 @@ class PocketViewModelTest {
2726
fun setup() {
2827
repoCacheState = PublishSubject.create()
2928
val repo = mock(PocketVideoRepo::class.java)
30-
`when`(repo.feedState).thenReturn(Observable.empty())
31-
val repoCache = object : PocketRepoCache(repo) {
32-
override val feedState
33-
get() = repoCacheState
34-
}
29+
`when`(repo.feedState).thenReturn(repoCacheState)
3530

36-
viewModel = PocketViewModel(repoCache)
31+
viewModel = PocketViewModel(repo)
3732
noKeyPlaceholders = PocketViewModel.noKeyPlaceholders
3833
testObserver = viewModel.state.test()
3934
}

0 commit comments

Comments
 (0)