@@ -28,6 +28,12 @@ const Home: React.FC = () => {
2828 const carThingStateRef = useRef ( carThingState )
2929 const [ needsPlaybackSetup , setNeedsPlaybackSetup ] = useState ( false )
3030
31+ const [ updateInfo , setUpdateInfo ] = useState < {
32+ currentVersion : string
33+ latestVersion : string
34+ downloadUrl : string
35+ } | null > ( null )
36+
3137 useEffect ( ( ) => {
3238 window . api . getStorageValue ( 'setupComplete' ) . then ( setupComplete => {
3339 if ( ! setupComplete ) navigate ( '/setup' )
@@ -40,7 +46,7 @@ const Home: React.FC = () => {
4046 carThingStateRef . current = state
4147 } )
4248
43- const timeout = setTimeout ( ( ) => {
49+ const stateTimeout = setTimeout ( ( ) => {
4450 if ( carThingStateRef . current !== null ) return
4551
4652 window . api . triggerCarThingStateUpdate ( )
@@ -50,9 +56,17 @@ const Home: React.FC = () => {
5056 if ( handler === null ) setNeedsPlaybackSetup ( true )
5157 } )
5258
59+ window . api . checkUpdate ( ) . then ( setUpdateInfo )
60+
61+ const checkUpdateInterval = setInterval (
62+ ( ) => window . api . checkUpdate ( ) . then ( setUpdateInfo ) ,
63+ 1000 * 60 * 30
64+ )
65+
5366 return ( ) => {
5467 removeListener ( )
55- clearTimeout ( timeout )
68+ clearTimeout ( stateTimeout )
69+ clearInterval ( checkUpdateInterval )
5670 }
5771 } , [ ] )
5872
@@ -119,6 +133,25 @@ const Home: React.FC = () => {
119133 </ button >
120134 </ div >
121135 ) : null }
136+ { updateInfo &&
137+ updateInfo . latestVersion !== updateInfo . currentVersion ? (
138+ < div className = { styles . update } >
139+ < div className = { styles . title } >
140+ < span className = "material-icons" > download</ span > A new
141+ GlanceThing update is available!
142+ </ div >
143+ < div className = { styles . content } >
144+ < p className = { styles . version } >
145+ { updateInfo . currentVersion } { ' ' }
146+ < span className = "material-icons" > arrow_forward</ span > { ' ' }
147+ { updateInfo . latestVersion }
148+ </ p >
149+ < button onClick = { ( ) => window . open ( updateInfo . downloadUrl ) } >
150+ Download < span className = "material-icons" > open_in_new</ span >
151+ </ button >
152+ </ div >
153+ </ div >
154+ ) : null }
122155 </ div >
123156 )
124157}
0 commit comments