Rename variable SCAN_TIMEOUT to ADV_EXPIRATION_TIME

This commit is contained in:
2026-06-27 14:26:53 +07:00
parent 9ed28e11d9
commit 99c17b1169
@@ -37,7 +37,6 @@ import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.TimeoutCancellationException import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds import kotlin.time.Duration.Companion.seconds
import kotlin.time.TimeSource import kotlin.time.TimeSource
import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.ExperimentalUuidApi
@@ -59,7 +58,7 @@ class ScannerViewModel(
private val scannerRepository: ScannerRepository private val scannerRepository: ScannerRepository
) : ViewModel() { ) : ViewModel() {
companion object { companion object {
private val SCAN_TIMEOUT = 5.seconds private val ADV_EXPIRATION_TIME = 5.seconds
private val CONNECTION_TIMEOUT = 5.seconds private val CONNECTION_TIMEOUT = 5.seconds
private const val MAX_LOG_ENTRIES = 50 private const val MAX_LOG_ENTRIES = 50
} }
@@ -142,7 +141,7 @@ class ScannerViewModel(
cleanupJob = viewModelScope.launch { cleanupJob = viewModelScope.launch {
while (advertisementMap.isNotEmpty() && isActive) { while (advertisementMap.isNotEmpty() && isActive) {
delay(5000) 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()) { if (keysToRemove.isNotEmpty()) {
keysToRemove.forEach { advertisementMap.remove(it) } keysToRemove.forEach { advertisementMap.remove(it) }
updateDeviceList() updateDeviceList()