mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2025-12-23 22:18:23 -05:00
Add timezone refresh functionality to scheduling and settings
- Introduced a global function to refresh the scheduling timezone display when settings change. - Implemented logic to clear existing timer intervals before setting a new one for server time updates. - Enhanced the settings form to trigger the timezone refresh upon relevant changes, improving user experience.
This commit is contained in:
@@ -707,6 +707,9 @@ function isMobileDevice() {
|
||||
return window.innerWidth <= 768 || /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
// Global variable to store current timer interval
|
||||
let serverTimeInterval = null;
|
||||
|
||||
/**
|
||||
* Update timezone display for mobile/desktop
|
||||
*/
|
||||
@@ -753,6 +756,12 @@ function loadServerTimezone() {
|
||||
const serverTimezone = data.general?.timezone || 'UTC';
|
||||
console.debug('Server timezone loaded:', serverTimezone);
|
||||
|
||||
// Clear any existing timer
|
||||
if (serverTimeInterval) {
|
||||
clearInterval(serverTimeInterval);
|
||||
serverTimeInterval = null;
|
||||
}
|
||||
|
||||
// Update timezone display with mobile handling
|
||||
updateTimezoneDisplay(serverTimezone);
|
||||
|
||||
@@ -762,8 +771,8 @@ function loadServerTimezone() {
|
||||
// Update time inputs to show server current time
|
||||
updateTimeInputsWithServerTime(serverTimezone);
|
||||
|
||||
// Update time every minute
|
||||
setInterval(() => updateServerTime(serverTimezone), 60000);
|
||||
// Set up new timer with current timezone
|
||||
serverTimeInterval = setInterval(() => updateServerTime(serverTimezone), 60000);
|
||||
|
||||
// Handle window resize to adjust mobile/desktop display
|
||||
window.addEventListener('resize', () => {
|
||||
@@ -777,6 +786,14 @@ function loadServerTimezone() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh timezone display and timer (called when timezone settings change)
|
||||
*/
|
||||
function refreshSchedulingTimezone() {
|
||||
console.debug('Refreshing scheduling timezone due to settings change');
|
||||
loadServerTimezone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the displayed current server time
|
||||
*/
|
||||
@@ -1004,5 +1021,8 @@ function resetDayCheckboxes() {
|
||||
}
|
||||
}
|
||||
|
||||
// Expose scheduling timezone refresh function globally
|
||||
window.refreshSchedulingTimezone = refreshSchedulingTimezone;
|
||||
|
||||
// Close the IIFE that wraps the script
|
||||
})();
|
||||
|
||||
@@ -3145,6 +3145,12 @@ const SettingsForms = {
|
||||
window.huntarrUI.connectEventSource();
|
||||
}
|
||||
|
||||
// Refresh scheduling timezone display
|
||||
if (typeof window.refreshSchedulingTimezone === 'function') {
|
||||
console.log('[SettingsForms] Refreshing scheduling timezone display');
|
||||
window.refreshSchedulingTimezone();
|
||||
}
|
||||
|
||||
// If we're currently on the logs section, trigger a refresh
|
||||
const currentSection = localStorage.getItem('huntarrCurrentSection') || 'home';
|
||||
if (currentSection === 'logs') {
|
||||
|
||||
Reference in New Issue
Block a user