Skip to content

Commit

Permalink
Change auto alarm delete behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanSarwar45 committed Apr 26, 2024
1 parent 3387db9 commit 8019459
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
4 changes: 1 addition & 3 deletions lib/alarm/logic/alarm_isolate.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
15 changes: 6 additions & 9 deletions lib/alarm/types/alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,11 @@ class Alarm extends CustomizableListItem {

Future<void> 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;
}
}
Expand Down Expand Up @@ -335,9 +332,9 @@ class Alarm extends CustomizableListItem {
}
}

void _delete() {
_markedForDeletion = true;
}
// void _delete() {
// _markedForDeletion = true;
// }

void setTime(Time time) {
_time = time;
Expand Down

0 comments on commit 8019459

Please sign in to comment.