From f0de01f9aa20201cb29d07f2f328dbc45618edd3 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Mon, 16 Nov 2026 08:16:37 +0100 Subject: [PATCH] Say Armed for HH:MM only after a real arm The home screen prefixed it to every publish() result, including the full-screen-intent refusal and sync errors. Co-Authored-By: Claude Opus 5.5 --- phone_app/lib/screens/home_screen.dart | 3 --- phone_app/lib/services/alarm_publisher.dart | 8 +++++--- phone_app/test/services/alarm_publisher_test.dart | 7 +++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/phone_app/lib/screens/home_screen.dart b/phone_app/lib/screens/home_screen.dart index 5516995..55f6aa2 100644 --- a/phone_app/lib/screens/home_screen.dart +++ b/phone_app/lib/screens/home_screen.dart @@ -139,9 +139,6 @@ class _HomeScreenState extends State { // publish attempt was the one at startup, so an alarm moved earlier here // never reached the PC at all. await _syncToPc(); - if (!mounted) return; - // Keep the armed time in the confirmation; the sync result follows it. - setState(() => _status = 'Armed for ${_fmt(_hour, _minute)}. $_status'); } /// Re-reads the policy and arms the alarm to match it. diff --git a/phone_app/lib/services/alarm_publisher.dart b/phone_app/lib/services/alarm_publisher.dart index 096e2dd..da2125f 100644 --- a/phone_app/lib/services/alarm_publisher.dart +++ b/phone_app/lib/services/alarm_publisher.dart @@ -61,11 +61,13 @@ class AlarmPublisher { } } -/// The success line; names the Clock app only when the handoff to it -/// completed before its timeout, so a silent timeout never claims it. +/// The success line, naming the armed time; names the Clock app only when +/// the handoff to it completed before its timeout, so a silent timeout +/// never claims it. Only reached after `arm()` succeeded. String syncedStatus(int hour, int minute, {required bool inClock}) { final time = '${hour.toString().padLeft(2, '0')}:' '${minute.toString().padLeft(2, '0')}'; - return inClock ? 'Synced to PC ✓ Clock app set $time ✓' : 'Synced to PC ✓'; + final synced = 'Armed for $time. Synced to PC ✓'; + return inClock ? '$synced Clock app set ✓' : synced; } diff --git a/phone_app/test/services/alarm_publisher_test.dart b/phone_app/test/services/alarm_publisher_test.dart index 7fe72ce..6c021d6 100644 --- a/phone_app/test/services/alarm_publisher_test.dart +++ b/phone_app/test/services/alarm_publisher_test.dart @@ -42,8 +42,11 @@ void main() { test('the Clock line names the time only when the handoff completed', () { expect( syncedStatus(6, 5, inClock: true), - 'Synced to PC ✓ Clock app set 06:05 ✓', + 'Armed for 06:05. Synced to PC ✓ Clock app set ✓', + ); + expect( + syncedStatus(6, 5, inClock: false), + 'Armed for 06:05. Synced to PC ✓', ); - expect(syncedStatus(6, 5, inClock: false), 'Synced to PC ✓'); }); }