1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00

Added back version check on ajaxSuccess

This commit is contained in:
Keivan Beigi 2015-02-07 10:25:38 -08:00
parent 8f8fe99a16
commit 8d03850de7
6 changed files with 42 additions and 25 deletions

View File

@ -34,6 +34,7 @@ module.exports = (function(){
} }
return false; return false;
}; };
$(document).ajaxError(function(event, xmlHttpRequest, ajaxOptions){ $(document).ajaxError(function(event, xmlHttpRequest, ajaxOptions){
if(xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) { if(xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) {
return undefined; return undefined;

View File

@ -2,6 +2,7 @@ var _ = require('underscore');
var Backbone = require('backbone'); var Backbone = require('backbone');
module.exports = function(){ module.exports = function(){
this.prototype.setFilter = function(filter, options){ this.prototype.setFilter = function(filter, options){
options = _.extend({reset : true}, options || {}); options = _.extend({reset : true}, options || {});
this.state.filterKey = filter[0]; this.state.filterKey = filter[0];
@ -15,10 +16,13 @@ module.exports = function(){
} }
} }
}; };
this.prototype.setFilterMode = function(mode, options){ this.prototype.setFilterMode = function(mode, options){
return this.setFilter(this.filterModes[mode], options); return this.setFilter(this.filterModes[mode], options);
}; };
var originalMakeFullCollection = this.prototype._makeFullCollection; var originalMakeFullCollection = this.prototype._makeFullCollection;
this.prototype._makeFullCollection = function(models, options){ this.prototype._makeFullCollection = function(models, options){
var self = this; var self = this;
self.shadowCollection = originalMakeFullCollection.call(this, models, options); self.shadowCollection = originalMakeFullCollection.call(this, models, options);
@ -30,18 +34,23 @@ module.exports = function(){
return model.get(self.state.filterKey) === self.state.filterValue; return model.get(self.state.filterKey) === self.state.filterValue;
} }
}; };
self.shadowCollection.filtered = function(){ self.shadowCollection.filtered = function(){
return this.filter(filterModel); return this.filter(filterModel);
}; };
var filteredModels = self.shadowCollection.filtered(); var filteredModels = self.shadowCollection.filtered();
var fullCollection = originalMakeFullCollection.call(this, filteredModels, options); var fullCollection = originalMakeFullCollection.call(this, filteredModels, options);
fullCollection.resetFiltered = function(options){ fullCollection.resetFiltered = function(options){
Backbone.Collection.prototype.reset.call(this, self.shadowCollection.filtered(), options); Backbone.Collection.prototype.reset.call(this, self.shadowCollection.filtered(), options);
}; };
fullCollection.reset = function(models, options){ fullCollection.reset = function(models, options){
self.shadowCollection.reset(models, options); self.shadowCollection.reset(models, options);
self.fullCollection.resetFiltered(); self.fullCollection.resetFiltered();
}; };
return fullCollection; return fullCollection;
}; };
_.extend(this.prototype.state, { _.extend(this.prototype.state, {

View File

@ -1,7 +1,9 @@
var vent = require('../vent'); var vent = require('../vent');
var AppLayout = require('../AppLayout'); var AppLayout = require('../AppLayout');
var Marionette = require('marionette'); var Marionette = require('marionette');
var NotFoundView = require('./NotFoundView'); var NotFoundView = require('./NotFoundView');
var Messenger = require('messenger');
module.exports = Marionette.AppRouter.extend({ module.exports = Marionette.AppRouter.extend({
initialize : function(){ initialize : function(){
@ -34,6 +36,20 @@ module.exports = Marionette.AppRouter.extend({
} }
}, },
_onServerUpdated : function(){ _onServerUpdated : function(){
Messenger.show({
message : 'Sonarr has been updated',
hideAfter : 0,
id : 'droneUpdated',
actions : {
viewChanges : {
label : 'View Changes',
action : function(){
window.location = window.NzbDrone.UrlBase + '/system/updates';
}
}
}
});
this.pendingUpdate = true; this.pendingUpdate = true;
}, },
showMainRegion : function(view){ showMainRegion : function(view){

View File

@ -0,0 +1,13 @@
var $ = require('jquery');
var vent = require('vent');
$(document).ajaxSuccess(function(event, xhr){
var version = xhr.getResponseHeader('X-ApplicationVersion');
if(!version || !window.NzbDrone || !window.NzbDrone.Version) {
return;
}
if(version !== window.NzbDrone.Version) {
vent.trigger(vent.Events.ServerUpdated);
}
});

View File

@ -20,28 +20,5 @@ module.exports = function(){
xhr.headers['X-Api-Key'] = window.NzbDrone.ApiKey; 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 : 'Sonarr has been updated', hideAfter : 0, id : 'droneUpdated', actions : {
viewChanges : {
label : 'View Changes', action : function () {
window.location = window.NzbDrone.UrlBase + '/system/updates';
}
}
}
});
vent.trigger(vent.Events.ServerUpdated);
}
});*/
}; };
}; };

View File

@ -17,6 +17,7 @@ require('./Instrumentation/StringFormat');
require('./LifeCycle'); require('./LifeCycle');
require('./Hotkeys/Hotkeys'); require('./Hotkeys/Hotkeys');
require('./Shared/piwikCheck'); require('./Shared/piwikCheck');
require('./Shared/VersionChangeMonitor');
new SeriesController(); new SeriesController();
new ModalController(); new ModalController();