Skip to content

Commit b7dc3c9

Browse files
author
Patrick Jackson
committed
use presenter-middleware 0.2.10
1 parent 54b9b2d commit b7dc3c9

File tree

16 files changed

+17
-673
lines changed

16 files changed

+17
-673
lines changed

android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ dependencies {
5656
implementation "android.arch.navigation:navigation-fragment-ktx:$ktxVersion"
5757
implementation "android.arch.navigation:navigation-ui-ktx:$ktxVersion"
5858
implementation "org.reduxkotlin:redux-kotlin:$reduxVersion"
59+
implementation "org.reduxkotlin:presenter-middleware:$reduxPresenterMiddlewareVersion"
5960
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
6061

61-
implementation "com.facebook.stetho:stetho:$stethoVersion"
62-
implementation "com.facebook.stetho:stetho-okhttp3:$stethoVersion"
6362
implementation "com.github.bumptech.glide:glide:$glideVersion"
6463
implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion"
6564

android/src/main/java/com/willowtreeapps/namegame/store/BaseNameGameViewFragment.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ package com.willowtreeapps.namegame.store
22

33
import android.os.Bundle
44
import androidx.fragment.app.Fragment
5-
import com.willowtreeapps.common.PresenterLifecycleObserver
65
import com.willowtreeapps.common.ui.GameBaseView
6+
import org.reduxkotlin.PresenterLifecycleObserver
77

88
open class BaseNameGameViewFragment<V: GameBaseView>: Fragment(), GameBaseView {
99
private val presenterObserver = PresenterLifecycleObserver(this)
10-
private var viewRecreated: Boolean = false
1110

1211
override fun onCreate(savedInstanceState: Bundle?) {
1312
retainInstance = true

android/src/main/java/com/willowtreeapps/namegame/store/GameResultsFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.willowtreeapps.common.middleware.UiActions
88
import com.willowtreeapps.common.ui.GameResultsViewState
99
import com.willowtreeapps.common.ui.GameResultsView
1010
import com.willowtreeapps.namegame.MainActivity
11-
import com.willowtreeapps.namegame.NameGameApp
1211
import com.willowtreeapps.namegame.R
1312
import com.willowtreeapps.namegame.dispatch
1413
import kotlinx.android.synthetic.main.fragment_game_results.*

android/src/main/java/com/willowtreeapps/namegame/store/SettingsDialogFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.willowtreeapps.namegame.MainActivity
1717
import com.willowtreeapps.namegame.R
1818
import com.willowtreeapps.namegame.dispatch
1919
import kotlinx.android.synthetic.main.fragment_settings.*
20+
import org.reduxkotlin.PresenterLifecycleObserver
2021

2122
class SettingsDialogFragment : DialogFragment(), SettingsView {
2223

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ ext {
4747
multiplatformSettingsVersion = '0.3.2'
4848
reduxVersion = '0.2.6'
4949
reduxThunkVersion = '0.2.8'
50-
reduxPresenterMiddlewareVersion = '0.2.8'
50+
reduxPresenterMiddlewareVersion = '0.2.10'
5151
reduxReselectVersion = '0.2.8'
5252
}

common/src/androidMain/kotlin/com/willowtreeapps/common/PresenterLifecycleObserver.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.

common/src/commonMain/kotlin/com/willowtreeapps/common/AppState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ enum class QuestionCategoryId(val displayName: String) {
7272
CATS("Cats");
7373

7474
companion object {
75-
val displayNameListWithoutWT by lazy {
75+
val displayNameList by lazy {
7676
values().map { it.displayName }
7777
}
7878

common/src/commonMain/kotlin/com/willowtreeapps/common/GameEngine.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
package com.willowtreeapps.common
22

3-
import com.willowtreeapps.common.external.presenterEnhancer
4-
import org.reduxkotlin.createStore
5-
import org.reduxkotlin.applyMiddleware
63
import com.willowtreeapps.common.middleware.*
74
import com.willowtreeapps.common.repo.LocalStorageSettingsRepository
85
import com.willowtreeapps.common.repo.userSettings
96
import com.willowtreeapps.common.util.VibrateUtil
107
import kotlinx.coroutines.CoroutineScope
118
import kotlinx.coroutines.launch
12-
import org.reduxkotlin.compose
13-
import org.reduxkotlin.createThunkMiddleware
9+
import org.reduxkotlin.*
1410
import kotlin.coroutines.CoroutineContext
1511

1612
class GameEngine(navigator: Navigator,

common/src/commonMain/kotlin/com/willowtreeapps/common/NetworkThunks.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import kotlin.coroutines.CoroutineContext
1212
* Thunks are functions that are executed by the "ThunkMiddleware". They are asynchronous and dispatch
1313
* actions. This allows dispatching a loading, success, and failure state.
1414
*/
15-
class NetworkThunks(private val networkContext: CoroutineContext) : CoroutineScope {
16-
private val job = Job()
17-
override val coroutineContext: CoroutineContext
18-
get() = networkContext + job
15+
class NetworkThunks(networkContext: CoroutineContext) {
16+
private val networkScope = CoroutineScope(networkContext)
1917

2018
//TODO cache the repositories
2119
private fun repoForCategory(categoryId: QuestionCategoryId) = when (categoryId) {
@@ -26,7 +24,7 @@ class NetworkThunks(private val networkContext: CoroutineContext) : CoroutineSco
2624
fun fetchItems(categoryId: QuestionCategoryId, numQuestions: Int) = thunk { dispatch, getState, extraArgument ->
2725
val repo = repoForCategory(categoryId)
2826
Logger.d("Fetching StoreInfo and Feed")
29-
launch {
27+
networkScope.launch {
3028
dispatch(Actions.FetchingItemsStartedAction())
3129
val result = repo.fetchItems(numQuestions)
3230
if (result.isSuccessful) {

common/src/commonMain/kotlin/com/willowtreeapps/common/boundary/TransformFunctions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fun AppState.toGameResultsViewState(): GameResultsViewState {
5656
fun UserSettings.toViewState(): SettingsViewState = SettingsViewState(
5757
numQuestions = numQuestions,
5858
categoryId = categoryId,
59-
categoryDisplayValues = QuestionCategoryId.displayNameListWithoutWT,
59+
categoryDisplayValues = QuestionCategoryId.displayNameList,
6060
isMicModeEnabled = microphoneMode
6161
)
6262

0 commit comments

Comments
 (0)