mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-18 08:26:27 +10:00
Fix race conditions
This commit is contained in:
@@ -413,10 +413,20 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
return;
|
||||
}
|
||||
|
||||
final pathBytes = Uint8List.fromList(path.pathBytes);
|
||||
final pathLength = path.pathBytes.length;
|
||||
|
||||
await connector.setContactPath(
|
||||
widget.contact,
|
||||
Uint8List.fromList(path.pathBytes),
|
||||
path.pathBytes.length,
|
||||
pathBytes,
|
||||
pathLength,
|
||||
);
|
||||
|
||||
// Update contact in memory directly for immediate UI feedback
|
||||
connector.updateContactInMemory(
|
||||
widget.contact.publicKeyHex,
|
||||
pathBytes: pathBytes,
|
||||
pathLength: pathLength,
|
||||
);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
@@ -184,7 +184,24 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
|
||||
}
|
||||
|
||||
if (_fetchedSettings.containsKey('tx')) {
|
||||
_txPowerController.text = _fetchedSettings['tx']!;
|
||||
final txValue = _fetchedSettings['tx']!;
|
||||
// Extract just the power value if it's part of a larger response
|
||||
// Handle formats like "10", "10 dBm", or "908.205017,62.5,10,7"
|
||||
final parts = txValue.split(',');
|
||||
if (parts.length >= 3) {
|
||||
// If comma-separated (likely radio format), TX power is typically the 3rd or 4th value
|
||||
// Format: freq,bandwidth,sf,cr OR freq,bandwidth,power,sf,cr
|
||||
final powerCandidate = parts.length > 3 ? parts[2].trim() : parts.last.trim();
|
||||
final powerInt = int.tryParse(powerCandidate.replaceAll(RegExp(r'[^0-9-]'), ''));
|
||||
if (powerInt != null && powerInt >= 1 && powerInt <= 30) {
|
||||
_txPowerController.text = powerInt.toString();
|
||||
} else {
|
||||
_txPowerController.text = txValue.replaceAll(RegExp(r'[^0-9-]'), '');
|
||||
}
|
||||
} else {
|
||||
// Simple format, just extract the number
|
||||
_txPowerController.text = txValue.replaceAll(RegExp(r'[^0-9-]'), '');
|
||||
}
|
||||
}
|
||||
|
||||
if (_fetchedSettings.containsKey('lat')) {
|
||||
|
||||
Reference in New Issue
Block a user