Skip to content

Commit b77c1db

Browse files
committed
fix: Improve notification scheduling accuracy and add debugging
Improved accuracy of reminder notifications, especially for those within 60 seconds of the scheduled time. Added debugging logs to ContentEditor and notificationService for improved troubleshooting.
1 parent c7f4c9e commit b77c1db

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.notask.app"
88
minSdkVersion rootProject.ext.minSdkVersion
99
targetSdkVersion rootProject.ext.targetSdkVersion
10-
versionCode 1518018
11-
versionName "15.18.18"
10+
versionCode 1518019
11+
versionName "15.18.19"
1212
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1313
aaptOptions {
1414
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"name": "my-notes-and-tasks-modern",
4-
"version": "15.18.18",
4+
"version": "15.18.19",
55
"private": true,
66
"license": "Licensed CC BY-ND 4.0. No derivatives allowed.",
77
"scripts": {

src/components/rpane/ContentEditor.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ const ContentEditor = memo(
6565

6666
// FIX: Use the reminder prop for the live countdown
6767
const liveCountdown = useLiveCountdown(reminder?.timestamp);
68+
69+
// Debug logging for reminder
70+
useEffect(() => {
71+
if (reminder) {
72+
console.log('📱 ContentEditor reminder debug:', {
73+
reminder,
74+
timestamp: reminder.timestamp,
75+
timestampType: typeof reminder.timestamp,
76+
liveCountdown,
77+
formatRemainingTime: formatRemainingTime(reminder.timestamp)
78+
});
79+
}
80+
}, [reminder, liveCountdown]);
6881

6982
// Auto-save implementation with proper integration
7083
const saveFunction = useCallback(async (data) => {

src/services/notificationService.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,25 @@ class NotificationService {
153153
// mapping we wouldn't know which notification ID to cancel on receipt.
154154
this.notificationIdMap[itemId] = safeId;
155155

156+
// For reminders within 60 seconds, schedule earlier to compensate for Android delays
157+
const now = Date.now();
158+
const timeUntilReminder = timestamp - now;
159+
let adjustedNotificationTime = notificationTime;
160+
161+
if (timeUntilReminder <= 60 * 1000) { // 60 seconds or less
162+
// Schedule 5 seconds earlier to compensate for system delays
163+
const compensationMs = Math.min(5000, timeUntilReminder * 0.5);
164+
adjustedNotificationTime = new Date(timestamp - compensationMs);
165+
console.log(`📱 Adjusting notification time by ${compensationMs}ms for better accuracy`);
166+
}
167+
156168
const notifications = [
157169
{
158170
title: '⏰ Reminder',
159171
body: `Don't forget: ${itemTitle || 'Untitled'}`,
160172
id: safeId,
161173
// Ensure alarms fire while idle on Android
162-
schedule: { at: notificationTime, allowWhileIdle: true },
174+
schedule: { at: adjustedNotificationTime, allowWhileIdle: true },
163175
// Always use the main reminders channel for consistent behavior
164176
channelId: 'reminders',
165177
importance: 5,

0 commit comments

Comments
 (0)