]> git.proxmox.com Git - proxmox-widget-toolkit.git/blobdiff - src/Utils.js
fix #4421: ui: guard setProxy against races of slow vs fast requests
[proxmox-widget-toolkit.git] / src / Utils.js
index f55b9a5371d3ca8948a5f65b12eabed1515f8554..8a974870540b6d5e428267a2f59c27da62b04170 100644 (file)
@@ -1451,3 +1451,18 @@ Ext.define('Proxmox.Async', {
        return new Promise((resolve, _reject) => setTimeout(resolve, millis));
     },
 });
+
+Ext.override(Ext.data.Store, {
+    // If the store's proxy is changed while it is waiting for an AJAX
+    // response, `onProxyLoad` will still be called for the outdated response.
+    // To avoid displaying inconsistent information, only process responses
+    // belonging to the current proxy.
+    onProxyLoad: function(operation) {
+       let me = this;
+       if (operation.getProxy() === me.getProxy()) {
+           me.callParent(arguments);
+       } else {
+           console.log(`ignored outdated response: ${operation.getRequest().getUrl()}`);
+       }
+    },
+});