Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Notify if new update available
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt committed Sep 3, 2016
1 parent 52a8691 commit 4bb555e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@ function getData() {

});

//// ASYNC FUNCTION CHECKING FOR UPDATE ///

var xhr = new XMLHttpRequest();

xhr.open("GET", "https://api.github.com/repos/vincelwt/harmony/releases", true);

xhr.onload = function (e) {
if (xhr.readyState === 4 && xhr.status === 200) {
var newUpdate = JSON.parse(xhr.responseText);

console.log("Latest release is "+newUpdate[0].tag_name);

if (newUpdate[0].tag_name > process.env.npm_package_version)
notifier.notify({'title': 'Update available', 'message': 'A new version of Harmony is available, visit the website'});

}

};

xhr.send(null);

///////////////////////////////////////

});

var retryTimer = setTimeout(function(){//After 45s
Expand Down

0 comments on commit 4bb555e

Please sign in to comment.