Auto reload when server has been updated

New: Updating will reload UI on navigation
This commit is contained in:
Mark McDowall 2014-05-11 17:44:42 -07:00
commit eff7c4b7b7
10 changed files with 98 additions and 31 deletions

View file

@ -28,6 +28,29 @@ define(
xhr.headers['X-Api-Key'] = window.NzbDrone.ApiKey;
}
return original.apply(this, arguments);
return original.apply(this, arguments).done(function (response, status, xhr){
var version = xhr.getResponseHeader('X-ApplicationVersion');
if (!window.NzbDrone || !window.NzbDrone.Version) {
return;
}
if (version !== window.NzbDrone.Version) {
var vent = require('vent');
var messenger = require('Shared/Messenger');
if (!vent || !messenger) {
return;
}
messenger.show({
message : 'NzbDrone has been updated',
hideAfter : 0,
id : 'droneUpdated'
});
vent.trigger(vent.Events.ServerUpdated);
}
});
};
});

View file

@ -19,7 +19,7 @@ define(
series: function () {
this.setTitle('NzbDrone');
AppLayout.mainRegion.show(new SeriesIndexLayout());
this.showMainRegion(new SeriesIndexLayout());
},
seriesDetails: function (query) {
@ -28,7 +28,7 @@ define(
if (series.length !== 0) {
var targetSeries = series[0];
this.setTitle(targetSeries.get('title'));
AppLayout.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries }));
this.showMainRegion(new SeriesDetailsLayout({ model: targetSeries }));
}
else {
this.showNotFound();

View file

@ -50,15 +50,6 @@ define(
this.signalRconnection.reconnected(function() {
tryingToReconnect = false;
var currentVersion = StatusModel.get('version');
var promise = StatusModel.fetch();
promise.done(function () {
if (StatusModel.get('version') !== currentVersion) {
vent.trigger(vent.Events.ServerUpdated);
}
});
});
this.signalRconnection.disconnected(function () {