@@ -153,10 +153,8 @@ const WailBrewApp = () => {
153153
154154 // Background update checking state
155155 const [ isBackgroundCheckRunning , setIsBackgroundCheckRunning ] = useState < boolean > ( false ) ;
156- const [ timeUntilNextCheck , setTimeUntilNextCheck ] = useState < number > ( 0 ) ;
157156 const lastKnownOutdatedCount = useRef < number > ( 0 ) ;
158157 const backgroundCheckInterval = useRef < ReturnType < typeof setInterval > | null > ( null ) ;
159- const timeUpdateInterval = useRef < ReturnType < typeof setInterval > | null > ( null ) ;
160158 const nextCheckTime = useRef < number > ( Date . now ( ) + 15 * 60 * 1000 ) ; // 15 minutes from now
161159
162160 // Track update event listeners for cleanup (prevents duplicate listeners bug)
@@ -392,9 +390,6 @@ const WailBrewApp = () => {
392390 if ( backgroundCheckInterval . current ) {
393391 clearInterval ( backgroundCheckInterval . current ) ;
394392 }
395- if ( timeUpdateInterval . current ) {
396- clearInterval ( timeUpdateInterval . current ) ;
397- }
398393 if ( loadingTimerInterval . current ) {
399394 clearInterval ( loadingTimerInterval . current ) ;
400395 }
@@ -558,13 +553,6 @@ const WailBrewApp = () => {
558553
559554 // Start background update checking
560555 const startBackgroundUpdateCheck = ( ) => {
561- // Update time until next check every second
562- timeUpdateInterval . current = setInterval ( ( ) => {
563- const now = Date . now ( ) ;
564- const timeRemaining = Math . max ( 0 , nextCheckTime . current - now ) ;
565- setTimeUntilNextCheck ( Math . floor ( timeRemaining / 1000 ) ) ; // Convert to seconds
566- } , 1000 ) ;
567-
568556 // Perform initial check after a short delay
569557 setTimeout ( ( ) => {
570558 performBackgroundUpdateCheck ( ) ;
@@ -576,17 +564,10 @@ const WailBrewApp = () => {
576564 } , 15 * 60 * 1000 ) ; // 15 minutes
577565 } ;
578566
579- // Format time until next check
580- const formatTimeUntilNextCheck = ( seconds : number ) : string => {
581- if ( seconds <= 0 ) return t ( 'backgroundCheck.checkingNow' ) ;
582-
583- const minutes = Math . floor ( seconds / 60 ) ;
584- const remainingSeconds = seconds % 60 ;
585-
586- if ( minutes > 0 ) {
587- return t ( 'backgroundCheck.nextCheckIn' , { minutes, seconds : remainingSeconds } ) ;
588- }
589- return t ( 'backgroundCheck.nextCheckInSeconds' , { seconds : remainingSeconds } ) ;
567+ // Get seconds until next background check (computed on demand, no re-renders)
568+ const getSecondsUntilNextCheck = ( ) : number => {
569+ const timeRemaining = Math . max ( 0 , nextCheckTime . current - Date . now ( ) ) ;
570+ return Math . floor ( timeRemaining / 1000 ) ;
590571 } ;
591572
592573 const checkAppUpdatesOnStartup = async ( ) => {
@@ -2016,8 +1997,7 @@ const WailBrewApp = () => {
20161997 sidebarWidth = { sidebarWidth }
20171998 sidebarRef = { sidebarRef }
20181999 isBackgroundCheckRunning = { isBackgroundCheckRunning }
2019- timeUntilNextCheck = { timeUntilNextCheck }
2020- formatTimeUntilNextCheck = { formatTimeUntilNextCheck }
2000+ getSecondsUntilNextCheck = { getSecondsUntilNextCheck }
20212001 />
20222002 < div
20232003 className = "sidebar-resize-handle"
0 commit comments