ui: tape/ChangerStatus: handle vanishing view during reload

since reload is an async function, the view can be destroyed during
any 'await' point. Subsequent accesses to the view will fail, and we
will land in the catch. Check there if the view is destroyed, and
do not raise an error with the user then

also cancel any outstanding timer on 'deactivate' and 'destroy'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak authored and Dietmar Maurer committed 2021-03-01 14:01:31 +01:00
1 parent 7eefd0c3d7
commit 9896a75caf
1 file changed
+13 -2
+13 -2
View File
@@ -285,12 +285,17 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
}
},
reload: function() {
cancelReload: function() {
let me = this;
if (me.reloadTimeout !== undefined) {
clearTimeout(me.reloadTimeout);
me.reloadTimeout = undefined;
}
},
reload: function() {
let me = this;
me.cancelReload();
me.reload_full(true);
},
@@ -398,6 +403,10 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
}
Proxmox.Utils.setErrorMask(me.lookup('content'));
} catch (err) {
if (!view || view.isDestroyed) {
return;
}
if (!use_cache) {
Proxmox.Utils.setErrorMask(view);
}
@@ -470,11 +479,13 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
}
view.title = `${gettext("Changer")}: ${view.changer}`;
me.reload();
},
},
listeners: {
activate: 'reload',
deactivate: 'cancelReload',
destroy: 'cancelReload',
},
tbar: [