Skip to content

Commit

Permalink
feat: check if new version is available (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneBour committed Apr 24, 2018
1 parent afe4a77 commit 3e37740
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</form>
<button class="pull-left btn btn-link"><span id="notification" style="visibility: hidden"
class="label label-info"></span></button>
<span id="new_version" style="font-weight:bold; padding: 10px 20px 10px;float: left;color: black;display:none;"><a href="https://github.com/StephaneBour/sense-chrome" target="_blank">A new version is available, make a "git pull"</a></span>
<button id="help_btn" class="btn pull-right-btn" data-toggle="modal" data-target="#help_popup">Help</button>
<button id="history_btn" class="btn pull-right-btn" data-toggle="modal" data-target="#history_popup">History
</button>
Expand Down
23 changes: 21 additions & 2 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,26 @@ function moveToNextRequestEdge() {

moveToNextRequestEdge = autoRetryIfTokenizing(moveToNextRequestEdge);

function checkVersion() {
var hashLocal = '';
fetch('.git/FETCH_HEAD')
.then(response => response.text())
.then(function(text) {
hashLocal = text.split("\t")[0];
console

fetch('https://api.github.com/repos/StephaneBour/sense-chrome/commits')
.then(response => response.json())
.then(function(github) {
if(github[0].sha !== hashLocal) {
document.getElementById('new_version').style.display = 'block';
}
});
});
}

moveToNextRequestEdge = autoRetryIfTokenizing(checkVersion);

function init() {

sense.editor = ace.edit("editor");
Expand Down Expand Up @@ -499,7 +519,6 @@ function init() {

sense.editor.getSession().on("changeScrollTop", updateEditorActionsBar);


sense.output = ace.edit("output");
sense.output.getSession().setMode("ace/mode/json");
sense.output.getSession().setFoldStyle('markbeginend');
Expand Down Expand Up @@ -535,7 +554,7 @@ function init() {
sense.history.init();
sense.saved.init();
sense.autocomplete.init();

checkVersion();
$("#send").tooltip();
$("#send").click(function () {
submitCurrentRequestToES();
Expand Down

0 comments on commit 3e37740

Please sign in to comment.