From 8ec63a7876f56b633d3dcdbdafabb58b7b2b2619 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Thu, 30 Oct 2025 07:19:54 +0000 Subject: [PATCH] feat(www): show prefetch and notification times in schedule success message Update www/index.html scheduleNotification() function to calculate and display both prefetch time (5 minutes before) and notification time in the success message, matching the behavior added to the development app assets version. This provides users with clear visibility into when the PBS prefetch will run and when the notification will actually fire. --- www/index.html | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/www/index.html b/www/index.html index 615d7cc..be40a1c 100644 --- a/www/index.html +++ b/www/index.html @@ -421,16 +421,38 @@ async function scheduleNotification() { updateStatus('info', '⏰ Scheduling notification...'); try { + const timeInput = document.getElementById('notificationTime').value; + const [hours, minutes] = timeInput.split(':'); + const now = new Date(); + const scheduledTime = new Date(); + scheduledTime.setHours(parseInt(hours), parseInt(minutes), 0, 0); + + // If scheduled time is in the past, schedule for tomorrow + if (scheduledTime <= now) { + scheduledTime.setDate(scheduledTime.getDate() + 1); + } + + // Calculate prefetch time (5 minutes before notification) + const prefetchTime = new Date(scheduledTime.getTime() - 300000); // 5 minutes + const prefetchTimeReadable = prefetchTime.toLocaleTimeString(); + const notificationTimeReadable = scheduledTime.toLocaleTimeString(); + const prefetchTimeString = prefetchTime.getHours().toString().padStart(2, '0') + ':' + + prefetchTime.getMinutes().toString().padStart(2, '0'); + const notificationTimeString = scheduledTime.getHours().toString().padStart(2, '0') + ':' + + scheduledTime.getMinutes().toString().padStart(2, '0'); + const options = { url: document.getElementById('notificationUrl').value, - time: document.getElementById('notificationTime').value, + time: timeInput, title: document.getElementById('notificationTitle').value, body: document.getElementById('notificationBody').value, sound: true, priority: 'high' }; await plugin.scheduleDailyNotification(options); - updateStatus('success', `⏰ Notification scheduled: ${JSON.stringify(options, null, 2)}`); + updateStatus('success', `✅ Notification scheduled!
` + + `📥 Prefetch: ${prefetchTimeReadable} (${prefetchTimeString})
` + + `🔔 Notification: ${notificationTimeReadable} (${notificationTimeString})`); } catch (error) { updateStatus('error', `❌ Scheduling failed: ${error.message}`); }