mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-01-28 02:54:31 +01:00
Revert "Clear repository when enter a screen"
This reverts commit 9354dd0b44.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ internal class CGMService : NotificationService() {
|
||||
}
|
||||
|
||||
private fun clear() {
|
||||
repository.clearRecords()
|
||||
repository.clear()
|
||||
}
|
||||
|
||||
private suspend fun requestLastRecord() {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user