Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix reminder toggle not honoured

laurenspriem7d6140e2cbf7
diff --git a/mobile/apps/photos/lib/models/rituals/ritual_models.dart b/mobile/apps/photos/lib/models/rituals/ritual_models.dart
index d983e8edd0..1223621f5c 100644
--- a/mobile/apps/photos/lib/models/rituals/ritual_models.dart
+++ b/mobile/apps/photos/lib/models/rituals/ritual_models.dart
@@ -18,6 +18,7 @@ class Ritual {
required this.title,
required this.daysOfWeek, // Sunday-first ordering of length 7
required this.timeOfDay,
+ required this.remindersEnabled,
required this.albumId,
required this.albumName,
required this.icon,
@@ -28,6 +29,7 @@ class Ritual {
final String title;
final List<bool> daysOfWeek;
final TimeOfDay timeOfDay;
+ final bool remindersEnabled;
final int? albumId;
final String? albumName;
final String icon;
@@ -38,6 +40,7 @@ class Ritual {
String? title,
List<bool>? daysOfWeek,
TimeOfDay? timeOfDay,
+ bool? remindersEnabled,
int? albumId,
String? albumName,
String? icon,
@@ -48,6 +51,7 @@ class Ritual {
title: title ?? this.title,
daysOfWeek: daysOfWeek ?? this.daysOfWeek,
timeOfDay: timeOfDay ?? this.timeOfDay,
+ remindersEnabled: remindersEnabled ?? this.remindersEnabled,
albumId: albumId ?? this.albumId,
albumName: albumName ?? this.albumName,
icon: icon ?? this.icon,
@@ -62,6 +66,7 @@ class Ritual {
"daysOfWeek": daysOfWeek,
"hour": timeOfDay.hour,
"minute": timeOfDay.minute,
+ "remindersEnabled": remindersEnabled,
"albumId": albumId,
"albumName": albumName,
"icon": icon,
@@ -70,6 +75,12 @@ class Ritual {
}
factory Ritual.fromJson(Map<String, dynamic> json) {
+ final rawRemindersEnabled = json["remindersEnabled"];
+ final remindersEnabled = rawRemindersEnabled is bool
+ ? rawRemindersEnabled
+ : rawRemindersEnabled is num
+ ? rawRemindersEnabled != 0
+ : true;
return Ritual(
id: json["id"] as String? ?? newID("ritual"),
title: json["title"] as String? ?? "",
@@ -80,6 +91,7 @@ class Ritual {
hour: (json["hour"] as num?)?.toInt() ?? 9,
minute: (json["minute"] as num?)?.toInt() ?? 0,
),
+ remindersEnabled: remindersEnabled,
albumId: (json["albumId"] as num?)?.toInt(),
albumName: json["albumName"] as String?,
icon: json["icon"] as String? ?? "πŸ“Έ",
diff --git a/mobile/apps/photos/lib/services/rituals/rituals_service.dart b/mobile/apps/photos/lib/services/rituals/rituals_service.dart
index 110832f48b..fc312301c1 100644
--- a/mobile/apps/photos/lib/services/rituals/rituals_service.dart
+++ b/mobile/apps/photos/lib/services/rituals/rituals_service.dart
@@ -464,13 +464,19 @@ class RitualsService {
_logger.info(
"Clearing scheduled notifications for ritual ${ritual.id} (save path)",
);
- _logger.info(
- "Scheduling ritual reminders for ritual ${ritual.id} (save path)",
- );
await NotificationService.instance.clearAllScheduledNotifications(
containingPayload: ritual.id,
logLines: false,
);
+ if (!ritual.remindersEnabled) {
+ _logger.info(
+ "Skipping scheduling ritual reminders for ritual ${ritual.id} (reminders disabled)",
+ );
+ return;
+ }
+ _logger.info(
+ "Scheduling ritual reminders for ritual ${ritual.id} (save path)",
+ );
final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
final baseId = ritual.id.hashCode & 0x7fffffff;
@@ -624,6 +630,7 @@ class RitualsService {
title: "",
daysOfWeek: List<bool>.filled(7, true),
timeOfDay: const TimeOfDay(hour: 9, minute: 0),
+ remindersEnabled: true,
albumId: null,
albumName: null,
icon: "πŸ“Έ",
diff --git a/mobile/apps/photos/lib/ui/rituals/ritual_editor_dialog.dart b/mobile/apps/photos/lib/ui/rituals/ritual_editor_dialog.dart
index b803600fba..7624e952dd 100644
--- a/mobile/apps/photos/lib/ui/rituals/ritual_editor_dialog.dart
+++ b/mobile/apps/photos/lib/ui/rituals/ritual_editor_dialog.dart
@@ -27,7 +27,7 @@ Future<void> _showRitualEditor(BuildContext context, {Ritual? ritual}) async {
ritual?.timeOfDay ?? const TimeOfDay(hour: 9, minute: 0);
String selectedEmoji = ritual?.icon ?? "πŸ“Έ";
final formKey = GlobalKey<FormState>();
- bool sendReminderEnabled = !days.every((selected) => !selected);
+ bool sendReminderEnabled = ritual?.remindersEnabled ?? true;
await showGeneralDialog(
context: context,
@@ -495,6 +495,7 @@ Future<void> _showRitualEditor(BuildContext context, {Ritual? ritual}) async {
title: controller.text.trim(),
daysOfWeek: days,
timeOfDay: selectedTime,
+ remindersEnabled: sendReminderEnabled,
albumId: selectedAlbumId,
albumName: selectedAlbumName,
icon: selectedEmoji,