From 4a2f360d456d87305d920366d5bb21770f824141 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 3 Apr 2020 08:50:39 +0200 Subject: [PATCH] update store: move store parameter into config, use getter/setter this allows to drop setting the default values and ensures that when interval is updated it actually effects the used update frequency. Anything which was saved in "me" before, for example me.autoStart, is still there and gets also updated on a me.setIsStopped(), so there should be no effects on code using internals. Signed-off-by: Thomas Lamprecht --- data/UpdateStore.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/data/UpdateStore.js b/data/UpdateStore.js index 77533ce..031ac6d 100644 --- a/data/UpdateStore.js +++ b/data/UpdateStore.js @@ -11,9 +11,13 @@ Ext.define('Proxmox.data.UpdateStore', { extend: 'Ext.data.Store', alias: 'store.update', - isStopped: true, + config: { + interval: 3000, - autoStart: false, + isStopped: true, + + autoStart: false, + }, destroy: function() { let me = this; @@ -26,10 +30,6 @@ Ext.define('Proxmox.data.UpdateStore', { config = config || {}; - if (!config.interval) { - config.interval = 3000; - } - if (!config.storeid) { throw "no storeid specified"; } @@ -37,7 +37,7 @@ Ext.define('Proxmox.data.UpdateStore', { let load_task = new Ext.util.DelayedTask(); let run_load_task = function() { - if (me.isStopped) { + if (me.getIsStopped()) { return; } @@ -45,7 +45,7 @@ Ext.define('Proxmox.data.UpdateStore', { let start = new Date(); me.load(function() { let runtime = (new Date()) - start; - let interval = config.interval + runtime*2; + let interval = me.getInterval() + runtime*2; load_task.delay(interval, run_load_task); }); } else { @@ -55,12 +55,12 @@ Ext.define('Proxmox.data.UpdateStore', { Ext.apply(config, { startUpdate: function() { - me.isStopped = false; + me.setIsStopped(false); // run_load_task(); this makes problems with chrome load_task.delay(1, run_load_task); }, stopUpdate: function() { - me.isStopped = true; + me.setIsStopped(true); load_task.cancel(); } }); @@ -69,7 +69,7 @@ Ext.define('Proxmox.data.UpdateStore', { me.load_task = load_task; - if (me.autoStart) { + if (me.getAutoStart()) { me.startUpdate(); } }