@@ -377,22 +377,6 @@ async function loadApp() {
377377
378378 new EditorFile ( ) ;
379379
380- checkPluginsUpdate ( )
381- . then ( ( updates ) => {
382- if ( ! updates . length ) return ;
383- acode . pushNotification (
384- "Plugin Updates" ,
385- `${ updates . length } plugin${ updates . length > 1 ? "s" : "" } ${ updates . length > 1 ? "have" : "has" } new version${ updates . length > 1 ? "s" : "" } available.` ,
386- {
387- icon : "extension" ,
388- action : ( ) => {
389- plugins ( updates ) ;
390- } ,
391- } ,
392- ) ;
393- } )
394- . catch ( console . error ) ;
395-
396380 //load plugins
397381 try {
398382 await loadPlugins ( ) ;
@@ -424,6 +408,58 @@ async function loadApp() {
424408
425409 initFileList ( ) ;
426410
411+ checkPluginsUpdate ( )
412+ . then ( ( updates ) => {
413+ if ( ! updates . length ) return ;
414+ acode . pushNotification (
415+ "Plugin Updates" ,
416+ `${ updates . length } plugin${ updates . length > 1 ? "s" : "" } ${ updates . length > 1 ? "have" : "has" } new version${ updates . length > 1 ? "s" : "" } available.` ,
417+ {
418+ icon : "extension" ,
419+ action : ( ) => {
420+ plugins ( updates ) ;
421+ } ,
422+ } ,
423+ ) ;
424+ } )
425+ . catch ( console . error ) ;
426+
427+ // Check for app updates
428+ if ( navigator . onLine ) {
429+ fetch ( "https://api.github.com/repos/deadlyjack/Acode/releases/latest" )
430+ . then ( ( res ) => res . json ( ) )
431+ . then ( ( release ) => {
432+ // assuming version is in format v1.2.3
433+ const latestVersion = release . tag_name
434+ . replace ( "v" , "" )
435+ . split ( "." )
436+ . map ( Number ) ;
437+ const currentVersion = BuildInfo . version . split ( "." ) . map ( Number ) ;
438+
439+ const hasUpdate = latestVersion . some (
440+ ( num , i ) => num > currentVersion [ i ] ,
441+ ) ;
442+
443+ if ( hasUpdate ) {
444+ acode . pushNotification (
445+ "Update Available" ,
446+ `Acode ${ release . tag_name } is now available! Click here to checkout.` ,
447+ {
448+ icon : "update" ,
449+ type : "warning" ,
450+ action : ( ) => {
451+ system . openInBrowser ( release . html_url ) ;
452+ } ,
453+ } ,
454+ ) ;
455+ }
456+ } )
457+ . catch ( ( err ) => {
458+ window . log ( "error" , "Failed to check for updates" ) ;
459+ window . log ( "error" , err ) ;
460+ } ) ;
461+ }
462+
427463 /**
428464 *
429465 * @param {MouseEvent } e
0 commit comments