From 2cdb642e849f8bcf69d262eb77a3379ee0bdfc3b Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Wed, 5 Aug 2026 09:32:06 +0200 Subject: [PATCH] Let a Firebase-only phone actually sync Spotted on the device right after installing the migrated app: the home screen still gated syncing on `settings.isConfigured`, which is only true when a **GitHub token** is stored. A phone connected to Firebase and nothing else would be told "Configure GitHub in Settings first" and refuse to push -- and once the GitHub mirror is retired, that would be every phone. Both the gate and the hint now accept either backend, matching what syncBackend() already does: Firebase alone, GitHub alone, or the mirror that writes both. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_017FH32BgGQbQLDstBhR26Xa --- phone_app/lib/screens/home_screen.dart | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/phone_app/lib/screens/home_screen.dart b/phone_app/lib/screens/home_screen.dart index b4ca033..466a2ea 100644 --- a/phone_app/lib/screens/home_screen.dart +++ b/phone_app/lib/screens/home_screen.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:wake_alarm_sync/screens/settings_screen.dart'; import 'package:wake_alarm_sync/services/alarm_sync_service.dart'; +import 'package:wake_alarm_sync/services/firebase_backend.dart'; import 'package:wake_alarm_sync/services/sync_settings.dart'; import 'package:wake_alarm_sync/ui/theme.dart'; @@ -43,9 +44,15 @@ class _HomeScreenState extends State { // hiccup): keep the on-screen defaults rather than crashing. return; } + // Either backend counts: a device connected only to Firebase is fully + // configured, and gating on the GitHub token alone would lock it out of + // syncing entirely once the mirror is retired. + final firebaseAccount = await loadAccount(); if (!mounted) return; _service = service; - setState(() => _configured = settings.isConfigured); + setState( + () => _configured = settings.isConfigured || firebaseAccount != null, + ); final alarm = service.currentAlarm; if (alarm != null && mounted) { @@ -91,8 +98,11 @@ class _HomeScreenState extends State { Future _syncAndSet() async { final settings = await SyncSettings.load(); final service = _service; - if (!settings.isConfigured || service == null) { - setState(() => _status = 'Configure GitHub in Settings first.'); + // syncBackend() falls back to GitHub alone, or pushes to Firebase alone + // via the mirror, so either credential is enough to proceed. + final hasFirebase = await loadAccount() != null; + if ((!settings.isConfigured && !hasFirebase) || service == null) { + setState(() => _status = 'Connect a sync backend in Settings first.'); return; } @@ -209,7 +219,7 @@ class _HomeScreenState extends State { if (!_configured) ...[ const SizedBox(height: 16), Text( - 'Open Settings (gear icon) to connect GitHub.', + 'Open Settings (gear icon) to connect Firebase.', textAlign: TextAlign.center, style: TextStyle( color: Theme.of(