Skip to content
Snippets Groups Projects
Unverified Commit 3baa2b39 authored by Ralf Gehrer's avatar Ralf Gehrer Committed by GitHub
Browse files

Remove manual refresh of last fetched timestamp (EXPOSUREAPP-3843) #1648

parent d38c1067
No related branches found
No related tags found
No related merge requests found
......@@ -5,9 +5,11 @@ import androidx.core.content.edit
import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.risk.RiskLevel
import de.rki.coronawarnapp.util.preferences.createFlowPreference
import de.rki.coronawarnapp.util.security.SecurityHelper.globalEncryptedSharedPreferencesInstance
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.map
import java.util.Date
/**
......@@ -399,6 +401,12 @@ object LocalData {
return Date(time)
}
fun lastTimeDiagnosisKeysFromServerFetchFlow() =
getSharedPreferenceInstance()
.createFlowPreference<Long?>(CoronaWarnApplication.getAppContext()
.getString(R.string.preference_timestamp_diagnosis_keys_fetch), 0L).flow
.map { if (it != null && it != 0L) Date(it) else null }
/**
* Sets the last time the server fetched the diagnosis keys from the server as Date object
* from the EncryptedSharedPrefs
......
......@@ -49,22 +49,11 @@ class TracingRepository @Inject constructor(
private val timeStamper: TimeStamper
) {
private val internalLastTimeDiagnosisKeysFetched = MutableStateFlow<Date?>(null)
val lastTimeDiagnosisKeysFetched: Flow<Date?> = internalLastTimeDiagnosisKeysFetched
val lastTimeDiagnosisKeysFetched: Flow<Date?> = LocalData.lastTimeDiagnosisKeysFromServerFetchFlow()
private val internalActiveTracingDaysInRetentionPeriod = MutableStateFlow(0L)
val activeTracingDaysInRetentionPeriod: Flow<Long> = internalActiveTracingDaysInRetentionPeriod
/**
* Refresh the last time diagnosis keys fetched date with the current shared preferences state.
*
* @see LocalData
*/
fun refreshLastTimeDiagnosisKeysFetchedDate() {
internalLastTimeDiagnosisKeysFetched.value =
LocalData.lastTimeDiagnosisKeysFromServerFetch()
}
private val internalIsRefreshing =
taskController.tasks.map { it.isDownloadDiagnosisKeysTaskRunning() || it.isRiskLevelTaskRunning() }
......@@ -104,7 +93,6 @@ class TracingRepository @Inject constructor(
)
)
taskController.submit(DefaultTaskRequest(RiskLevelTask::class))
refreshLastTimeDiagnosisKeysFetchedDate()
TimerHelper.startManualKeyRetrievalTimer()
}
}
......@@ -152,7 +140,6 @@ class TracingRepository @Inject constructor(
DownloadDiagnosisKeysTask.Arguments()
)
)
refreshLastTimeDiagnosisKeysFetchedDate()
TimerHelper.checkManualKeyRetrievalTimer()
taskController.submit(DefaultTaskRequest(RiskLevelTask::class))
......
......@@ -104,7 +104,6 @@ class HomeFragmentViewModel @AssistedInject constructor(
// TODO the ordering here is weird, do we expect these to run in sequence?
tracingRepository.refreshRiskLevel()
tracingRepository.refreshExposureSummary()
tracingRepository.refreshLastTimeDiagnosisKeysFetchedDate()
tracingRepository.refreshActiveTracingDaysInRetentionPeriod()
TimerHelper.checkManualKeyRetrievalTimer()
tracingRepository.refreshLastSuccessfullyCalculatedScore()
......
......@@ -37,7 +37,6 @@ class RiskDetailsFragmentViewModel @AssistedInject constructor(
fun refreshData() {
tracingRepository.refreshRiskLevel()
tracingRepository.refreshExposureSummary()
tracingRepository.refreshLastTimeDiagnosisKeysFetchedDate()
TimerHelper.checkManualKeyRetrievalTimer()
tracingRepository.refreshActiveTracingDaysInRetentionPeriod()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment