AeroToss: исправлен поиск после потери связи + убрана лишняя кнопка
- onBroadcastReceived: обновляет device если IP/name изменились - Убрана FAB 'Обновить' внизу (осталась TextButton 'Обновить' справа) - Устройства снова видят друг друга после переподключения
This commit is contained in:
@@ -151,10 +151,20 @@ class TcpDiscovery(
|
||||
if (remoteId == deviceId) return
|
||||
if (remoteServicePort == myServicePort) return
|
||||
|
||||
// Skip if already known
|
||||
if (discoveredDevices.containsKey(remoteId)) return
|
||||
|
||||
val host = pkt.address.hostAddress ?: return
|
||||
|
||||
// Update existing device if IP or name changed (e.g. after reconnect)
|
||||
val existing = discoveredDevices[remoteId]
|
||||
if (existing != null) {
|
||||
if (existing.hostAddress != host || existing.name != remoteName) {
|
||||
val updated = existing.copy(hostAddress = host, name = remoteName)
|
||||
discoveredDevices[remoteId] = updated
|
||||
_devices.value = discoveredDevices.values.toList()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// New device - query it
|
||||
val device = queryRemote(host, remoteTcpPort)
|
||||
if (device != null) {
|
||||
discoveredDevices[device.id] = device
|
||||
|
||||
@@ -35,13 +35,6 @@ fun HomeScreen(
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
FloatingActionButton(
|
||||
onClick = { manager.rescan() },
|
||||
containerColor = MaterialTheme.colorScheme.tertiaryContainer
|
||||
) {
|
||||
Text("Обновить", style = MaterialTheme.typography.labelLarge)
|
||||
}
|
||||
FloatingActionButton(
|
||||
onClick = onReceiveClick,
|
||||
containerColor = MaterialTheme.colorScheme.secondaryContainer
|
||||
@@ -49,7 +42,6 @@ fun HomeScreen(
|
||||
Text("Получить", style = MaterialTheme.typography.labelLarge)
|
||||
}
|
||||
}
|
||||
}
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
|
||||
Reference in New Issue
Block a user