]> git.proxmox.com Git - pmg-gui.git/commitdiff
quarantine list: factor out restoreSavedSelection
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 1 Apr 2021 11:39:36 +0000 (13:39 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 1 Apr 2021 11:39:36 +0000 (13:39 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
js/QuarantineList.js

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