Skip to content

Commit

Permalink
Release 1.0.7 - Fixes version timeout, fixes break after first failure (
Browse files Browse the repository at this point in the history
#15)

clear setTimeout when component is destroyed

Should not stop updating if one request fails
  • Loading branch information
Jarrod Seccombe authored and sethwebster committed May 12, 2016
1 parent dacd727 commit 93a0b6b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
19 changes: 12 additions & 7 deletions addon/components/new-version-notifier/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,23 @@ export default Ember.Component.extend({
Ember.$.ajax(self.get('url'), { cache:false }).then(function(res){
var currentVersion = self.get('version');
var newVersion = res && res.trim();

if (currentVersion && self.compareVersions(newVersion, currentVersion) === -1) {
var message = self.get("updateMessage")
.replace("{{oldVersion}}",currentVersion)
.replace("{{newVersion}}",newVersion);

self.setProperties({
message,
lastVersion: currentVersion
});
}

self.set('version',newVersion);
self.set('_timeout',setTimeout(function() {
self.updateVersion();
},self.get('updateInterval')));
}).always(function() {
self.set('_timeout', setTimeout(function() {
self.updateVersion();
}, self.get('updateInterval')));
});
}, 10);
self.set('_timeout', t);
Expand All @@ -78,11 +79,15 @@ export default Ember.Component.extend({

return 0;
},
willDestroy() {
this._super(...arguments);
clearTimeout(this.get('_timeout'));
},
actions: {
reload() {
location.reload();
},

close() {
this.set('message', undefined);
}
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"ember-qunit": "0.4.16",
"ember-qunit-notifications": "0.1.0",
"ember-resolver": "~0.1.20",
"jquery": "^1.11.3",
"jquery": "1.11.3",
"loader.js": "ember-cli/loader.js#3.4.0",
"qunit": "~1.20.0"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-cli-new-version",
"version": "1.0.6",
"version": "1.0.7",
"description": "A convention based update notification for Ember. With this addon, you can detect a new version and notify the user to refresh the page",
"directories": {
"doc": "doc",
Expand Down

0 comments on commit 93a0b6b

Please sign in to comment.