From 8019459cc5eed328cea2b530c0cc016dd44dcb06 Mon Sep 17 00:00:00 2001 From: AhsanSarwar45 Date: Fri, 26 Apr 2024 23:42:44 +0500 Subject: [PATCH] Change auto alarm delete behaviour --- lib/alarm/logic/alarm_isolate.dart | 4 +--- lib/alarm/types/alarm.dart | 15 ++++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/alarm/logic/alarm_isolate.dart b/lib/alarm/logic/alarm_isolate.dart index 9f03a170..272a0b71 100644 --- a/lib/alarm/logic/alarm_isolate.dart +++ b/lib/alarm/logic/alarm_isolate.dart @@ -1,8 +1,6 @@ import 'dart:isolate'; import 'dart:ui'; -import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart'; -import 'package:clock_app/alarm/logic/alarm_reminder_notifications.dart'; import 'package:clock_app/common/types/json.dart'; import 'package:clock_app/common/types/notification_type.dart'; import 'package:clock_app/common/utils/list_storage.dart'; @@ -84,7 +82,6 @@ void triggerAlarm(int scheduleId, Json params) async { } Alarm? alarm = getAlarmById(scheduleId); - await updateAlarmById(scheduleId, (alarm) async => alarm.handleTrigger()); DateTime now = DateTime.now(); // if alarm is triggered more than 10 minutes after the scheduled time, ignore @@ -158,6 +155,7 @@ void stopAlarm(int scheduleId, AlarmStopAction action) async { } } RingingManager.stopAlarm(); + await updateAlarmById(scheduleId, (alarm) async => alarm.handleDismiss()); } void triggerTimer(int scheduleId, Json params) async { diff --git a/lib/alarm/types/alarm.dart b/lib/alarm/types/alarm.dart index 11a778c6..e008b4d0 100644 --- a/lib/alarm/types/alarm.dart +++ b/lib/alarm/types/alarm.dart @@ -289,14 +289,11 @@ class Alarm extends CustomizableListItem { Future finish() async { await disable(); - if (shouldDeleteAfterFinish) { - _delete(); - } - // _isFinished = true; + // _isFinished = true; } - void handleTrigger() { - if (scheduleType == OnceAlarmSchedule && shouldDeleteAfterRinging) { + void handleDismiss() { + if (scheduleType == OnceAlarmSchedule && shouldDeleteAfterRinging || shouldDeleteAfterFinish && isFinished) { _markedForDeletion = true; } } @@ -335,9 +332,9 @@ class Alarm extends CustomizableListItem { } } - void _delete() { - _markedForDeletion = true; - } + // void _delete() { + // _markedForDeletion = true; + // } void setTime(Time time) { _time = time;