Add midnight fallback notice, overnight simulations, and keyboard log filter
This commit is contained in:
@@ -29,8 +29,7 @@ class BackgroundRotateCommand {
|
||||
action = BackgroundRotateAction.random;
|
||||
}
|
||||
|
||||
final backgroundRotateCommandProvider =
|
||||
StateProvider<BackgroundRotateCommand>(
|
||||
final backgroundRotateCommandProvider = StateProvider<BackgroundRotateCommand>(
|
||||
(ref) => const BackgroundRotateCommand.initial(),
|
||||
);
|
||||
|
||||
@@ -101,6 +100,44 @@ final todayScheduleProvider = Provider<DailyPrayerSchedule?>((ref) {
|
||||
return SyncService.instance.getTodaySchedule(clock);
|
||||
});
|
||||
|
||||
class RuntimeScheduleData {
|
||||
final DailyPrayerSchedule? schedule;
|
||||
final bool isFallbackFromPreviousDay;
|
||||
|
||||
const RuntimeScheduleData({
|
||||
required this.schedule,
|
||||
this.isFallbackFromPreviousDay = false,
|
||||
});
|
||||
|
||||
const RuntimeScheduleData.empty()
|
||||
: schedule = null,
|
||||
isFallbackFromPreviousDay = false;
|
||||
}
|
||||
|
||||
/// Runtime schedule used by main display/state machine.
|
||||
/// If today's data is missing after midnight, we temporarily fallback to yesterday
|
||||
/// so screen remains operational while showing a waiting-for-update notice.
|
||||
final runtimeScheduleProvider = Provider<RuntimeScheduleData>((ref) {
|
||||
final clock = ref.watch(clockProvider).valueOrNull;
|
||||
if (clock == null) return const RuntimeScheduleData.empty();
|
||||
|
||||
final today = SyncService.instance.getTodaySchedule(clock);
|
||||
if (today != null) {
|
||||
return RuntimeScheduleData(schedule: today);
|
||||
}
|
||||
|
||||
final previousDay = clock.subtract(const Duration(days: 1));
|
||||
final fallback = SyncService.instance.getTodaySchedule(previousDay);
|
||||
if (fallback != null) {
|
||||
return RuntimeScheduleData(
|
||||
schedule: fallback,
|
||||
isFallbackFromPreviousDay: true,
|
||||
);
|
||||
}
|
||||
|
||||
return const RuntimeScheduleData.empty();
|
||||
});
|
||||
|
||||
final scheduleCacheStatusProvider = Provider<ScheduleCacheStatus>((ref) {
|
||||
final clock = ref.watch(clockProvider).valueOrNull ?? DateTime.now();
|
||||
return SyncService.instance.getCacheStatus(clock);
|
||||
@@ -149,7 +186,7 @@ class ScreenStateData {
|
||||
|
||||
final screenStateProvider = Provider<ScreenStateData>((ref) {
|
||||
final clock = ref.watch(clockProvider).valueOrNull ?? DateTime.now();
|
||||
final schedule = ref.watch(todayScheduleProvider);
|
||||
final schedule = ref.watch(runtimeScheduleProvider).schedule;
|
||||
final settings = ref.watch(settingsProvider);
|
||||
final isFriday = clock.weekday == DateTime.friday;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user