1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-26 22:46:53 -04:00
Files
Radarr/src/UI/Shared/NzbDroneController.js
T
Devin Buhl 59c07cc5f3 Patch/onedr0p 3 16 17 (#1200)
* clear localStorage on radarr update.. ya mon

* Fix when movie folder is deleted from disk and keeps showing up as downloaded in radarr

* Clear all UI localStorage items on update, set pageSize to what it needs to be.
2017-03-16 18:43:06 -04:00

75 lines
2.4 KiB
JavaScript

var vent = require('vent');
var AppLayout = require('../AppLayout');
var Marionette = require('marionette');
var NotFoundView = require('./NotFoundView');
var Messenger = require('./Messenger');
var Config = require('../Config');
module.exports = Marionette.AppRouter.extend({
initialize : function() {
this.listenTo(vent, vent.Events.ServerUpdated, this._onServerUpdated);
},
showNotFound : function() {
this.setTitle('Not Found');
this.showMainRegion(new NotFoundView(this));
},
setTitle : function(title) {
title = title;
if (title === 'Radarr') {
document.title = 'Radarr';
} else {
document.title = title + ' - Radarr';
}
if (window.NzbDrone.Analytics && window.Piwik) {
try {
var piwik = window.Piwik.getTracker(window.location.protocol + '//piwik.nzbdrone.com/piwik.php', 1);
piwik.setReferrerUrl('');
piwik.setCustomUrl('http://local' + window.location.pathname);
piwik.setCustomVariable(1, 'version', window.NzbDrone.Version, 'page');
piwik.setCustomVariable(2, 'branch', window.NzbDrone.Branch, 'page');
piwik.trackPageView(title);
}
catch (e) {
console.error(e);
}
}
},
_onServerUpdated : function() {
var label = window.location.pathname === window.NzbDrone.UrlBase + '/system/updates' ? 'Reload' : 'View Changes';
Messenger.show({
message : 'Radarr has been updated, some UI configuration has been reset',
hideAfter : 0,
id : 'sonarrUpdated',
actions : {
viewChanges : {
label : label,
action : function() {
window.location = window.NzbDrone.UrlBase + '/system/updates';
}
}
}
});
// Only for pre-release development
var pageSize = Config.getValue("pageSize");
window.localStorage.clear();
Config.setValue("pageSize", pageSize);
// Remove above when out of pre-release :)
this.pendingUpdate = true;
},
showMainRegion : function(view) {
if (this.pendingUpdate) {
window.location.reload();
} else {
AppLayout.mainRegion.show(view);
}
}
});