quarantine list: factor out restoreSavedSelection

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-04-01 13:39:36 +02:00
parent 0e26e20aa5
commit 9b4247fbf2

View File

@ -80,8 +80,20 @@ Ext.define('PMG.QuarantineList', {
// to keep the selection, but we do not care for that on a new load anyway // to keep the selection, but we do not care for that on a new load anyway
view.getSelectionModel().deselectAll(); view.getSelectionModel().deselectAll();
store.load(function() { store.load(() => {
me.restoreSavedSelection();
if (Ext.isFunction(callback)) {
callback();
}
me.allowPositionSave = true;
});
},
restoreSavedSelection: function() {
let me = this;
let view = me.getView();
if (me.savedPosition !== undefined) { if (me.savedPosition !== undefined) {
let store = view.getStore();
if (store.getCount() - 1 < me.savedPosition) { if (store.getCount() - 1 < me.savedPosition) {
me.savedPosition = store.getCount() - 1; me.savedPosition = store.getCount() - 1;
} }
@ -89,11 +101,6 @@ Ext.define('PMG.QuarantineList', {
} else { } else {
view.setSelection(); view.setSelection();
} }
if (Ext.isFunction(callback)) {
callback();
}
me.allowPositionSave = true;
});
}, },
setFrom: function(from) { setFrom: function(from) {