feat: add comprehensive logging for UI refresh and capture JS console logs
- Add detailed logging to loadPluginStatus() with [UI Refresh] prefix - Add detailed logging to checkNotificationDelivery() with [Poll] prefix - Log status check results, change detection, and refresh triggers - Log nextNotificationTime comparisons to debug rollover detection - Include Capacitor/Console in logcat capture pattern to capture JS logs - Log notification delivery detection and time calculations - Log when rollover is detected and UI refresh is triggered This enables debugging of UI auto-refresh mechanism and visibility into JavaScript console logs in captured logcat output.
This commit is contained in:
@@ -799,7 +799,8 @@ main() {
|
||||
# Capture post-rollover state
|
||||
capture_alarms "test0_after_rollover"
|
||||
# Look for rollover logs: DN|RESCHEDULE, DN|DISPLAY, DN|RECEIVE, ROLLOVER_ON_FIRE, etc.
|
||||
capture_logcat "test0_after_rollover" "DN|RESCHEDULE|DN|DISPLAY|DN|RECEIVE|ROLLOVER|DNP-SCHEDULE" 200
|
||||
# Also capture JavaScript console logs (Capacitor/Console) for UI debugging
|
||||
capture_logcat "test0_after_rollover" "DN|RESCHEDULE|DN|DISPLAY|DN|RECEIVE|ROLLOVER|DNP-SCHEDULE|Capacitor/Console" 200
|
||||
capture_screenshot "test0_after_rollover"
|
||||
|
||||
step_pass "p1_t0_s4" "Post-rollover evidence captured"
|
||||
|
||||
@@ -182,32 +182,52 @@
|
||||
}
|
||||
|
||||
function loadPluginStatus() {
|
||||
console.log('loadPluginStatus called');
|
||||
console.log('[UI Refresh] loadPluginStatus called');
|
||||
const pluginStatusContent = document.getElementById('pluginStatusContent');
|
||||
const statusCard = document.getElementById('statusCard');
|
||||
|
||||
try {
|
||||
if (!window.DailyNotification) {
|
||||
console.warn('[UI Refresh] DailyNotification plugin not available');
|
||||
pluginStatusContent.innerHTML = '❌ DailyNotification plugin not available';
|
||||
statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
return;
|
||||
}
|
||||
console.log('[UI Refresh] Calling getNotificationStatus()...');
|
||||
window.DailyNotification.getNotificationStatus()
|
||||
.then(result => {
|
||||
console.log('[UI Refresh] getNotificationStatus result:', {
|
||||
nextNotificationTime: result.nextNotificationTime,
|
||||
isEnabled: result.isEnabled,
|
||||
pending: result.pending,
|
||||
lastNotificationTime: result.lastNotificationTime
|
||||
});
|
||||
|
||||
const nextTime = formatDateTimeNormalized(result.nextNotificationTime);
|
||||
const hasSchedules = result.isEnabled || (result.pending && result.pending > 0);
|
||||
const statusIcon = hasSchedules ? '✅' : '⏸️';
|
||||
|
||||
console.log('[UI Refresh] Updating UI:', {
|
||||
nextTime: nextTime,
|
||||
hasSchedules: hasSchedules,
|
||||
statusIcon: statusIcon
|
||||
});
|
||||
|
||||
pluginStatusContent.innerHTML = `${statusIcon} Active Schedules: ${hasSchedules ? 'Yes' : 'No'}<br>
|
||||
📅 Next Notification: ${nextTime}<br>
|
||||
⏳ Pending: ${result.pending || 0}`;
|
||||
statusCard.style.background = hasSchedules ?
|
||||
'rgba(0, 255, 0, 0.15)' : 'rgba(255, 255, 255, 0.1)'; // Green if active, light gray if none
|
||||
|
||||
console.log('[UI Refresh] UI updated successfully');
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('[UI Refresh] getNotificationStatus failed:', error);
|
||||
pluginStatusContent.innerHTML = `⚠️ Status check failed: ${error.message}`;
|
||||
statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[UI Refresh] loadPluginStatus exception:', error);
|
||||
pluginStatusContent.innerHTML = `⚠️ Status check failed: ${error.message}`;
|
||||
statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
}
|
||||
@@ -444,18 +464,36 @@
|
||||
|
||||
// Check for notification delivery and status updates periodically
|
||||
function checkNotificationDelivery() {
|
||||
if (!window.DailyNotification) return;
|
||||
if (!window.DailyNotification) {
|
||||
console.log('[Poll] DailyNotification not available, skipping check');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[Poll] checkNotificationDelivery called');
|
||||
window.DailyNotification.getNotificationStatus()
|
||||
.then(result => {
|
||||
console.log('[Poll] Status check result:', {
|
||||
nextNotificationTime: result.nextNotificationTime,
|
||||
lastNotificationTime: result.lastNotificationTime,
|
||||
lastKnownNextNotificationTime: lastKnownNextNotificationTime
|
||||
});
|
||||
|
||||
// Check for notification delivery
|
||||
if (result.lastNotificationTime) {
|
||||
const lastTime = new Date(result.lastNotificationTime);
|
||||
const now = new Date();
|
||||
const timeDiff = now - lastTime;
|
||||
|
||||
console.log('[Poll] Notification delivery check:', {
|
||||
lastTime: lastTime.toISOString(),
|
||||
now: now.toISOString(),
|
||||
timeDiff: timeDiff,
|
||||
withinWindow: timeDiff > 0 && timeDiff < 120000
|
||||
});
|
||||
|
||||
// If notification was received in the last 2 minutes, show indicator
|
||||
if (timeDiff > 0 && timeDiff < 120000) {
|
||||
console.log('[Poll] Notification received recently, showing indicator');
|
||||
const indicator = document.getElementById('notificationReceivedIndicator');
|
||||
const timeSpan = document.getElementById('notificationReceivedTime');
|
||||
|
||||
@@ -471,7 +509,9 @@
|
||||
}, 30000);
|
||||
|
||||
// Force immediate refresh when notification is received (rollover may have occurred)
|
||||
console.log('[Poll] Scheduling UI refresh in 1 second (waiting for rollover)...');
|
||||
setTimeout(() => {
|
||||
console.log('[Poll] Triggering UI refresh after notification received');
|
||||
loadPluginStatus();
|
||||
}, 1000); // Wait 1 second for rollover to complete
|
||||
}
|
||||
@@ -480,20 +520,37 @@
|
||||
|
||||
// Detect if nextNotificationTime changed (rollover occurred)
|
||||
const currentNextTime = result.nextNotificationTime;
|
||||
console.log('[Poll] Comparing nextNotificationTime:', {
|
||||
current: currentNextTime,
|
||||
lastKnown: lastKnownNextNotificationTime,
|
||||
changed: currentNextTime && currentNextTime !== lastKnownNextNotificationTime
|
||||
});
|
||||
|
||||
if (currentNextTime && currentNextTime !== lastKnownNextNotificationTime) {
|
||||
if (lastKnownNextNotificationTime !== null) {
|
||||
console.log('Next notification time changed - rollover detected!');
|
||||
console.log('[Poll] ⚠️ Next notification time changed - rollover detected!', {
|
||||
old: lastKnownNextNotificationTime,
|
||||
new: currentNextTime,
|
||||
oldDate: new Date(lastKnownNextNotificationTime).toISOString(),
|
||||
newDate: new Date(currentNextTime).toISOString()
|
||||
});
|
||||
// Force immediate refresh
|
||||
loadPluginStatus();
|
||||
} else {
|
||||
console.log('[Poll] Initializing lastKnownNextNotificationTime:', currentNextTime);
|
||||
}
|
||||
lastKnownNextNotificationTime = currentNextTime;
|
||||
} else {
|
||||
console.log('[Poll] No change detected in nextNotificationTime');
|
||||
}
|
||||
|
||||
// Auto-refresh plugin status periodically to show updated next notification time after rollover
|
||||
// This ensures the UI updates when the plugin reschedules the notification
|
||||
console.log('[Poll] Triggering periodic UI refresh');
|
||||
loadPluginStatus();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('[Poll] Status check failed:', error);
|
||||
// Silently fail - this is just for visual feedback
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user