mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
bugfix: retry notification should now only show up if you did NOT yet
take the supplement on that day.
This commit is contained in:
@@ -173,21 +173,36 @@ class NotificationService {
|
||||
// Call the callback to record the intake
|
||||
if (_onTakeSupplementCallback != null) {
|
||||
print('SupplementsLog: 📱 Calling supplement callback...');
|
||||
_onTakeSupplementCallback!(supplementId, supplementName, units, unitType);
|
||||
_onTakeSupplementCallback!(
|
||||
supplementId, supplementName, units, unitType);
|
||||
print('SupplementsLog: 📱 Callback completed');
|
||||
} else {
|
||||
print('SupplementsLog: 📱 ERROR: No callback registered!');
|
||||
}
|
||||
|
||||
// Mark notification as taken in database (this will cancel any pending retries)
|
||||
if (notificationId != null) {
|
||||
print('SupplementsLog: 📱 Marking notification $notificationId as taken');
|
||||
await DatabaseHelper.instance.markNotificationTaken(notificationId);
|
||||
|
||||
// Cancel any pending retry notifications for this notification
|
||||
_cancelRetryNotifications(notificationId);
|
||||
// For retry notifications, the original notification ID is in the payload
|
||||
int originalNotificationId;
|
||||
if (parts.length > 4 && int.tryParse(parts[4]) != null) {
|
||||
originalNotificationId = int.parse(parts[4]);
|
||||
print(
|
||||
'SupplementsLog: 📱 Retry notification detected. Original ID: $originalNotificationId');
|
||||
} else if (notificationId != null) {
|
||||
originalNotificationId = notificationId;
|
||||
} else {
|
||||
print(
|
||||
'SupplementsLog: 📱 ERROR: Could not determine notification ID to cancel.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark notification as taken in database (this will cancel any pending retries)
|
||||
print(
|
||||
'SupplementsLog: 📱 Marking notification $originalNotificationId as taken');
|
||||
await DatabaseHelper.instance
|
||||
.markNotificationTaken(originalNotificationId);
|
||||
|
||||
// Cancel any pending retry notifications for this notification
|
||||
_cancelRetryNotifications(originalNotificationId);
|
||||
|
||||
// Show a confirmation notification
|
||||
print('SupplementsLog: 📱 Showing confirmation notification...');
|
||||
showInstantNotification(
|
||||
@@ -195,7 +210,8 @@ class NotificationService {
|
||||
'$supplementName has been recorded at ${DateTime.now().hour.toString().padLeft(2, '0')}:${DateTime.now().minute.toString().padLeft(2, '0')}',
|
||||
);
|
||||
} else {
|
||||
print('SupplementsLog: 📱 ERROR: Invalid payload format - not enough parts');
|
||||
print(
|
||||
'SupplementsLog: 📱 ERROR: Invalid payload format - not enough parts');
|
||||
}
|
||||
} catch (e) {
|
||||
print('SupplementsLog: 📱 ERROR in _handleTakeAction: $e');
|
||||
|
Reference in New Issue
Block a user