Refactor: Implement global cooldown for Traceroute button (#2129)

This commit is contained in:
James Rich 2025-06-16 11:48:08 +00:00 committed by GitHub
parent 4683f5b9f2
commit a5ade9252a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 81 additions and 41 deletions

View file

@ -179,7 +179,7 @@ data class Contact(
val nodeColors: Pair<Int, Int>? = null,
)
@Suppress("LongParameterList")
@Suppress("LongParameterList", "LargeClass")
@HiltViewModel
class UIViewModel @Inject constructor(
private val app: Application,
@ -203,6 +203,9 @@ class UIViewModel @Inject constructor(
preferences.edit { putInt("theme", theme) }
}
private val _lastTraceRouteTime = MutableStateFlow<Long?>(null)
val lastTraceRouteTime: StateFlow<Long?> = _lastTraceRouteTime.asStateFlow()
data class AlertData(
val title: String,
val message: String? = null,
@ -252,7 +255,6 @@ class UIViewModel @Inject constructor(
val receivingLocationUpdates: StateFlow<Boolean> get() = locationRepository.receivingLocationUpdates
val meshService: IMeshService? get() = radioConfigRepository.meshService
val bondedAddress get() = radioInterfaceService.getBondedDeviceAddress()
val selectedBluetooth get() = radioInterfaceService.getDeviceAddress()?.getOrNull(0) == 'x'
private val _localConfig = MutableStateFlow<LocalConfig>(LocalConfig.getDefaultInstance())
@ -707,7 +709,11 @@ class UIViewModel @Inject constructor(
is NodeMenuAction.Favorite -> favoriteNode(action.node)
is NodeMenuAction.RequestUserInfo -> requestUserInfo(action.node.num)
is NodeMenuAction.RequestPosition -> requestPosition(action.node.num)
is NodeMenuAction.TraceRoute -> requestTraceroute(action.node.num)
is NodeMenuAction.TraceRoute -> {
requestTraceroute(action.node.num)
_lastTraceRouteTime.value = System.currentTimeMillis()
}
else -> {}
}
}