Browse Source

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.
master
Matthew Raymer 2 days ago
parent
commit
8ec63a7876
  1. 26
      www/index.html

26
www/index.html

@ -421,16 +421,38 @@
async function scheduleNotification() { async function scheduleNotification() {
updateStatus('info', '⏰ Scheduling notification...'); updateStatus('info', '⏰ Scheduling notification...');
try { 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 = { const options = {
url: document.getElementById('notificationUrl').value, url: document.getElementById('notificationUrl').value,
time: document.getElementById('notificationTime').value, time: timeInput,
title: document.getElementById('notificationTitle').value, title: document.getElementById('notificationTitle').value,
body: document.getElementById('notificationBody').value, body: document.getElementById('notificationBody').value,
sound: true, sound: true,
priority: 'high' priority: 'high'
}; };
await plugin.scheduleDailyNotification(options); await plugin.scheduleDailyNotification(options);
updateStatus('success', `⏰ Notification scheduled: ${JSON.stringify(options, null, 2)}`); updateStatus('success', `✅ Notification scheduled!<br>` +
`📥 Prefetch: ${prefetchTimeReadable} (${prefetchTimeString})<br>` +
`🔔 Notification: ${notificationTimeReadable} (${notificationTimeString})`);
} catch (error) { } catch (error) {
updateStatus('error', `❌ Scheduling failed: ${error.message}`); updateStatus('error', `❌ Scheduling failed: ${error.message}`);
} }

Loading…
Cancel
Save