Commit 962a7b82 authored by Dietmar Maurer's avatar Dietmar Maurer

UpdateQueue: add callback

So that we can queue new things after loading is done.
parent 4643f689
...@@ -15,30 +15,40 @@ Ext.define('PVE.data.UpdateQueue', { ...@@ -15,30 +15,40 @@ Ext.define('PVE.data.UpdateQueue', {
return; return;
} }
var store = queue.shift(); var storeid = queue.shift();
if (!store) { if (!storeid) {
return; return;
} }
var info = queue_idx[storeid];
queue_idx[storeid] = null;
queue_idx[store.storeid] = null; info.updatestart = new Date();
idle = false; idle = false;
store.load({ info.store.load({
callback: function(records, operation, success) { callback: function(records, operation, success) {
idle = true; idle = true;
if (info.callback) {
var runtime = (new Date()).getTime() - info.updatestart.getTime();
info.callback(runtime, success);
}
start_update(); start_update();
} }
}); });
}; };
Ext.apply(me, { Ext.apply(me, {
queue: function(store) { queue: function(store, cb) {
if (!store.storeid) { var storeid = store.storeid;
if (!storeid) {
throw "unable to queue store without storeid"; throw "unable to queue store without storeid";
} }
if (!queue_idx[store.storeid]) { if (!queue_idx[storeid]) {
queue_idx[store.storeid] = store; queue_idx[storeid] = {
queue.push(store); store: store,
callback: cb
};
queue.push(storeid);
} }
start_update(); start_update();
} }
......
...@@ -18,8 +18,9 @@ Ext.define('PVE.data.UpdateStore', { ...@@ -18,8 +18,9 @@ Ext.define('PVE.data.UpdateStore', {
var run_load_task = function() { var run_load_task = function() {
if (PVE.Utils.authOK()) { if (PVE.Utils.authOK()) {
PVE.data.UpdateQueue.queue(me); PVE.data.UpdateQueue.queue(me, function(runtime, success) {
load_task.delay(config.interval, run_load_task); load_task.delay(config.interval, run_load_task);
});
} else { } else {
load_task.delay(200, run_load_task); load_task.delay(200, run_load_task);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment