From d7d197ca841ae741f522e64f1b6e564c23f960c8 Mon Sep 17 00:00:00 2001 From: zjs81 Date: Sun, 27 Sep 2026 12:10:10 -0700 Subject: [PATCH] Fix self telemetry timeout handling and disconnected stats button - Cancel the self-request timeout when sendFrame throws, so a failed send no longer shows a second timeout snackbar or reschedules auto-refresh twice. - Do not wait for respCodeSent on self requests: none is sent for a local request, so any that arrives belongs to another send and replaced the 5s self timeout. - Disable the Radio Stats telemetry button while disconnected, matching the Settings tile. --- lib/screens/companion_radio_stats_screen.dart | 13 +++++++++---- lib/screens/telemetry_screen.dart | 5 ++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/screens/companion_radio_stats_screen.dart b/lib/screens/companion_radio_stats_screen.dart index 78618036..748f4a20 100644 --- a/lib/screens/companion_radio_stats_screen.dart +++ b/lib/screens/companion_radio_stats_screen.dart @@ -79,10 +79,15 @@ class _CompanionRadioStatsScreenState extends State { title: Text(l10n.radioStats_screenTitle), centerTitle: true, actions: [ - IconButton( - icon: const Icon(Icons.thermostat), - tooltip: l10n.contact_telemetry, - onPressed: () => pushSelfTelemetryScreen(context), + Selector( + selector: (_, c) => c.isConnected, + builder: (context, connected, _) => IconButton( + icon: const Icon(Icons.thermostat), + tooltip: l10n.contact_telemetry, + onPressed: connected + ? () => pushSelfTelemetryScreen(context) + : null, + ), ), ], ), diff --git a/lib/screens/telemetry_screen.dart b/lib/screens/telemetry_screen.dart index 10b68592..76cff5be 100644 --- a/lib/screens/telemetry_screen.dart +++ b/lib/screens/telemetry_screen.dart @@ -275,10 +275,13 @@ class _TelemetryScreenState extends State { frame = buildSendTelemetryReq(widget.contact.publicKey); } } - _awaitingSent = true; + // A local self request gets no respCodeSent, so any that arrives belongs + // to another send and must not replace the 5s self timeout. + _awaitingSent = !widget.isSelf; await connector.sendFrame(frame); } catch (e) { _awaitingSent = false; + _statusTimeout?.cancel(); if (mounted) { setState(() { _isLoading = false;