mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-10 19:27:02 +01:00
Let a Firebase-only phone actually sync
Some checks failed
Some checks failed
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017FH32BgGQbQLDstBhR26Xa
This commit is contained in:
parent
98f6c5c26c
commit
2cdb642e84
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:wake_alarm_sync/screens/settings_screen.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/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/services/sync_settings.dart';
|
||||||
import 'package:wake_alarm_sync/ui/theme.dart';
|
import 'package:wake_alarm_sync/ui/theme.dart';
|
||||||
|
|
||||||
@ -43,9 +44,15 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
// hiccup): keep the on-screen defaults rather than crashing.
|
// hiccup): keep the on-screen defaults rather than crashing.
|
||||||
return;
|
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;
|
if (!mounted) return;
|
||||||
_service = service;
|
_service = service;
|
||||||
setState(() => _configured = settings.isConfigured);
|
setState(
|
||||||
|
() => _configured = settings.isConfigured || firebaseAccount != null,
|
||||||
|
);
|
||||||
|
|
||||||
final alarm = service.currentAlarm;
|
final alarm = service.currentAlarm;
|
||||||
if (alarm != null && mounted) {
|
if (alarm != null && mounted) {
|
||||||
@ -91,8 +98,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
Future<void> _syncAndSet() async {
|
Future<void> _syncAndSet() async {
|
||||||
final settings = await SyncSettings.load();
|
final settings = await SyncSettings.load();
|
||||||
final service = _service;
|
final service = _service;
|
||||||
if (!settings.isConfigured || service == null) {
|
// syncBackend() falls back to GitHub alone, or pushes to Firebase alone
|
||||||
setState(() => _status = 'Configure GitHub in Settings first.');
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +219,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
if (!_configured) ...[
|
if (!_configured) ...[
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
'Open Settings (gear icon) to connect GitHub.',
|
'Open Settings (gear icon) to connect Firebase.',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(
|
color: Theme.of(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user