diff --git a/composeApp/src/commonMain/kotlin/com/digitoolsolutions/app/torquevaultkmp/screens/scanner/ScannerViewModel.kt b/composeApp/src/commonMain/kotlin/com/digitoolsolutions/app/torquevaultkmp/screens/scanner/ScannerViewModel.kt index cdeb465..9160ac0 100644 --- a/composeApp/src/commonMain/kotlin/com/digitoolsolutions/app/torquevaultkmp/screens/scanner/ScannerViewModel.kt +++ b/composeApp/src/commonMain/kotlin/com/digitoolsolutions/app/torquevaultkmp/screens/scanner/ScannerViewModel.kt @@ -37,7 +37,6 @@ import kotlinx.coroutines.withTimeout import kotlinx.coroutines.TimeoutCancellationException import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map -import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds import kotlin.time.TimeSource import kotlin.uuid.ExperimentalUuidApi @@ -59,7 +58,7 @@ class ScannerViewModel( private val scannerRepository: ScannerRepository ) : ViewModel() { companion object { - private val SCAN_TIMEOUT = 5.seconds + private val ADV_EXPIRATION_TIME = 5.seconds private val CONNECTION_TIMEOUT = 5.seconds private const val MAX_LOG_ENTRIES = 50 } @@ -142,7 +141,7 @@ class ScannerViewModel( cleanupJob = viewModelScope.launch { while (advertisementMap.isNotEmpty() && isActive) { delay(5000) - val keysToRemove = advertisementMap.filter { it.value.timeMark.elapsedNow() > SCAN_TIMEOUT }.keys + val keysToRemove = advertisementMap.filter { it.value.timeMark.elapsedNow() > ADV_EXPIRATION_TIME }.keys if (keysToRemove.isNotEmpty()) { keysToRemove.forEach { advertisementMap.remove(it) } updateDeviceList()