Revert "Clear repository when enter a screen"

This reverts commit 9354dd0b44.
This commit is contained in:
Sylwester Zielinski
2023-04-26 12:44:28 +02:00
parent 9354dd0b44
commit c5b808cd4f
16 changed files with 26 additions and 60 deletions

View File

@@ -32,6 +32,7 @@
package no.nordicsemi.android.cgms.repository
import android.content.Context
import android.util.Log
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
@@ -105,15 +106,12 @@ class CGMRepository @Inject constructor(
_data.value = _data.value.copy(deviceName = device.name)
}
fun clearRecords() {
fun clear() {
_data.value = _data.value.copy(records = emptyList())
}
fun stop() {
fun release() {
_data.value = CGMServiceData()
_stopEvent.tryEmit(DisconnectAndStopEvent())
}
fun clear() {
_data.value = CGMServiceData()
}
}

View File

@@ -286,7 +286,7 @@ internal class CGMService : NotificationService() {
}
private fun clear() {
repository.clearRecords()
repository.clear()
}
private suspend fun requestLastRecord() {

View File

@@ -67,8 +67,6 @@ internal class CGMViewModel @Inject constructor(
val state = repository.data
init {
repository.clear()
viewModelScope.launch {
if (repository.isRunning.firstOrNull() == false) {
requestBluetoothDevice()
@@ -115,6 +113,6 @@ internal class CGMViewModel @Inject constructor(
}
private fun disconnect() {
repository.stop()
repository.release()
}
}