@@ -21,14 +21,17 @@ const is_newer = (latest: string, current: string) => {
2121 return false
2222}
2323
24- export const use_update_check = ( current_version : string , is_active : boolean ) => {
25- const [ update_info , set_update_info ] = useState < UpdateInfo > ( global_update_info )
24+ export const use_update_check = (
25+ current_version : string ,
26+ is_active : boolean
27+ ) => {
28+ const [ update_info , set_update_info ] =
29+ useState < UpdateInfo > ( global_update_info )
2630
2731 useEffect ( ( ) => {
2832 if ( ! is_active || ! current_version ) {
2933 return
3034 }
31- let is_mounted = true
3235 let timeout_id : ReturnType < typeof setTimeout >
3336
3437 const check = async ( ) => {
@@ -56,7 +59,8 @@ export const use_update_check = (current_version: string, is_active: boolean) =>
5659 const date = commit_data . commit ?. committer ?. date
5760 if ( date ) {
5861 age_days = Math . floor (
59- ( Date . now ( ) - new Date ( date ) . getTime ( ) ) / ( 1000 * 60 * 60 * 24 )
62+ ( Date . now ( ) - new Date ( date ) . getTime ( ) ) /
63+ ( 1000 * 60 * 60 * 24 )
6064 )
6165 }
6266 }
@@ -69,9 +73,7 @@ export const use_update_check = (current_version: string, is_active: boolean) =>
6973 latest_version,
7074 current_version_age_days : age_days
7175 }
72- if ( is_mounted ) {
73- set_update_info ( global_update_info )
74- }
76+ set_update_info ( global_update_info )
7577 }
7678 break
7779 }
@@ -81,18 +83,15 @@ export const use_update_check = (current_version: string, is_active: boolean) =>
8183 console . error ( 'Failed to check for updates:' , e )
8284 }
8385
84- if ( is_mounted ) {
85- timeout_id = setTimeout ( check , CHECK_INTERVAL )
86- }
86+ timeout_id = setTimeout ( check , CHECK_INTERVAL )
8787 }
8888
8989 check ( )
9090
9191 return ( ) => {
92- is_mounted = false
9392 clearTimeout ( timeout_id )
9493 }
9594 } , [ current_version , is_active ] )
9695
9796 return update_info
98- }
97+ }
0 commit comments