@@ -3763,51 +3763,75 @@ let huntarrUI = {
37633763 console . log ( '[huntarrUI] Refreshing state management timezone displays due to settings change' ) ;
37643764
37653765 try {
3766- // First, tell the backend to clear its timezone cache
3767- HuntarrUtils . fetchWithTimeout ( './api/stateful/refresh-timezone' , {
3768- method : 'POST' ,
3769- headers : { 'Content-Type' : 'application/json' }
3770- } )
3771- . then ( response => response . json ( ) )
3772- . then ( data => {
3773- if ( data . success ) {
3774- console . log ( '[huntarrUI] Backend timezone cache cleared for state management' ) ;
3775- } else {
3776- console . warn ( '[huntarrUI] Failed to clear backend timezone cache:' , data . message ) ;
3777- }
3778- } )
3779- . catch ( error => {
3780- console . warn ( '[huntarrUI] Error clearing backend timezone cache:' , error ) ;
3781- } ) ;
3782-
3783- // Refresh all visible state management displays
3784- const supportedApps = [ 'sonarr' , 'radarr' , 'lidarr' , 'readarr' , 'whisparr' , 'eros' ] ;
3766+ // Simply reload the displays - the backend will use the new timezone automatically
3767+ this . reloadStateManagementDisplays ( ) ;
37853768
3786- supportedApps . forEach ( appType => {
3787- // Find all instance containers for this app
3788- const appPanel = document . getElementById ( `${ appType } -panel` ) ;
3789- if ( appPanel && appPanel . style . display !== 'none' ) {
3790- // Look for instance containers
3791- const instanceContainers = appPanel . querySelectorAll ( `[id^="${ appType } -instance-"]` ) ;
3792-
3793- instanceContainers . forEach ( ( container , index ) => {
3794- // Check if state management is enabled for this instance
3795- const stateStatusElement = document . getElementById ( `${ appType } -state-status-${ index } ` ) ;
3796- if ( stateStatusElement && stateStatusElement . style . display !== 'none' ) {
3797- console . log ( `[huntarrUI] Refreshing state management for ${ appType } instance ${ index } ` ) ;
3798- // Reload state info for this instance to get updated timezone
3799- this . loadInstanceStateInfo ( appType , index ) ;
3800- }
3801- } ) ;
3802- }
3803- } ) ;
3804-
3805- console . log ( '[huntarrUI] State management timezone refresh completed' ) ;
38063769 } catch ( error ) {
38073770 console . error ( '[huntarrUI] Error refreshing state management timezone:' , error ) ;
38083771 }
38093772 } ,
38103773
3774+ // Reload state management displays after timezone change
3775+ reloadStateManagementDisplays : function ( ) {
3776+ console . log ( '[huntarrUI] Reloading state management displays after timezone change' ) ;
3777+
3778+ // Refresh all visible state management displays
3779+ const supportedApps = [ 'sonarr' , 'radarr' , 'lidarr' , 'readarr' , 'whisparr' , 'eros' ] ;
3780+
3781+ supportedApps . forEach ( appType => {
3782+ // Find all instance containers for this app
3783+ const appPanel = document . getElementById ( `${ appType } -panel` ) ;
3784+ if ( appPanel && appPanel . style . display !== 'none' ) {
3785+ // Look for state reset time elements
3786+ const stateElements = appPanel . querySelectorAll ( `[id*="${ appType } -state-reset-time-"]` ) ;
3787+
3788+ stateElements . forEach ( element => {
3789+ // Extract instance index from element ID
3790+ const match = element . id . match ( / ( \w + ) - s t a t e - r e s e t - t i m e - ( \d + ) / ) ;
3791+ if ( match ) {
3792+ const instanceIndex = parseInt ( match [ 2 ] ) ;
3793+
3794+ // Get instance name from the form
3795+ const instanceNameElement = document . querySelector ( `#${ appType } -instance-name-${ instanceIndex } ` ) ;
3796+ if ( instanceNameElement ) {
3797+ const instanceName = instanceNameElement . value || 'Default' ;
3798+
3799+ console . log ( `[huntarrUI] Reloading state management for ${ appType } instance ${ instanceIndex } (${ instanceName } )` ) ;
3800+
3801+ // Fetch fresh state management data
3802+ this . loadStateManagementForInstance ( appType , instanceIndex , instanceName ) ;
3803+ }
3804+ }
3805+ } ) ;
3806+ }
3807+ } ) ;
3808+
3809+ console . log ( '[huntarrUI] State management timezone refresh completed' ) ;
3810+ } ,
3811+
3812+ // Load state management data for a specific instance
3813+ loadStateManagementForInstance : function ( appType , instanceIndex , instanceName ) {
3814+ const url = `./api/stateful/summary?app_type=${ encodeURIComponent ( appType ) } &instance_name=${ encodeURIComponent ( instanceName ) } ` ;
3815+
3816+ HuntarrUtils . fetchWithTimeout ( url , {
3817+ method : 'GET'
3818+ } )
3819+ . then ( response => response . json ( ) )
3820+ . then ( data => {
3821+ if ( data . success ) {
3822+ console . log ( `[huntarrUI] Received updated state management data for ${ appType } /${ instanceName } :` , data ) ;
3823+
3824+ // Update the display with the new timezone-converted data
3825+ this . updateInstanceStateDisplay ( appType , instanceIndex , data , instanceName , data . expiration_hours ) ;
3826+ } else {
3827+ console . warn ( `[huntarrUI] Failed to get state management data for ${ appType } /${ instanceName } :` , data . message || 'Unknown error' ) ;
3828+ }
3829+ } )
3830+ . catch ( error => {
3831+ console . error ( `[huntarrUI] Error loading state management data for ${ appType } /${ instanceName } :` , error ) ;
3832+ } ) ;
3833+ } ,
3834+
38113835 showRequestarrSidebar : function ( ) {
38123836 // Hide main sidebar and settings sidebar
38133837 const mainSidebar = document . getElementById ( 'sidebar' ) ;
0 commit comments