|
@@ -3,13 +3,8 @@ package com.sirekanian.acf
|
|
|
import com.sirekanian.acf.data.Repository
|
|
import com.sirekanian.acf.data.Repository
|
|
|
import com.sirekanian.acf.data.Warmonger
|
|
import com.sirekanian.acf.data.Warmonger
|
|
|
import kotlinx.coroutines.Dispatchers.IO
|
|
import kotlinx.coroutines.Dispatchers.IO
|
|
|
-import kotlinx.coroutines.delay
|
|
|
|
|
import kotlinx.coroutines.flow.Flow
|
|
import kotlinx.coroutines.flow.Flow
|
|
|
import kotlinx.coroutines.withContext
|
|
import kotlinx.coroutines.withContext
|
|
|
-import kotlin.time.Duration.Companion.minutes
|
|
|
|
|
-import kotlin.time.Duration.Companion.seconds
|
|
|
|
|
-
|
|
|
|
|
-private val UPDATE_PERIOD = if (BuildConfig.DEBUG) 20.seconds else 5.minutes
|
|
|
|
|
|
|
|
|
|
fun createPresenter(app: App, state: MainState): MainPresenter =
|
|
fun createPresenter(app: App, state: MainState): MainPresenter =
|
|
|
MainPresenterImpl(app.repository, state)
|
|
MainPresenterImpl(app.repository, state)
|
|
@@ -33,10 +28,7 @@ class MainPresenterImpl(
|
|
|
|
|
|
|
|
override suspend fun updateData() =
|
|
override suspend fun updateData() =
|
|
|
withContext(IO) {
|
|
withContext(IO) {
|
|
|
- while (true) {
|
|
|
|
|
- repository.updateFromRemote(state.progress)
|
|
|
|
|
- delay(UPDATE_PERIOD)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ repository.updateFromRemote(state.progress)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|