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.
This commit is contained in:
@@ -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!<br>` +
|
||||
`📥 Prefetch: ${prefetchTimeReadable} (${prefetchTimeString})<br>` +
|
||||
`🔔 Notification: ${notificationTimeReadable} (${notificationTimeString})`);
|
||||
} catch (error) {
|
||||
updateStatus('error', `❌ Scheduling failed: ${error.message}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user