Răsfoiți Sursa

HUE-6317 [editor] Fix the apihelper cache for metadata calls

Johan Ahlen 8 ani în urmă
părinte
comite
265a441
1 a modificat fișierele cu 7 adăugiri și 1 ștergeri
  1. 7 1
      desktop/core/src/desktop/static/desktop/js/apiHelper.js

+ 7 - 1
desktop/core/src/desktop/static/desktop/js/apiHelper.js

@@ -1700,7 +1700,8 @@ var ApiHelper = (function () {
       url: url,
       hash: hash,
       cacheType: 'optimizer',
-      fetchFunction: fetchFunction
+      fetchFunction: fetchFunction,
+      promise: promise
     }));
   };
 
@@ -1854,6 +1855,7 @@ var ApiHelper = (function () {
    * @param {Function} options.successCallback
    * @param {string} [options.cacheType] - Possible values 'default'|'optimizer'. Default value 'default'
    * @param {Object} [options.editor] - Ace editor
+   * @param {Object} [options.promise] - Optional promise that will be resolved if cached data exists
    */
   var fetchCached = function (options) {
     var self = this;
@@ -1873,6 +1875,10 @@ var ApiHelper = (function () {
         $.totalStorage(cacheIdentifier, cachedData);
       });
     } else {
+      if (options.promise) {
+        options.promise.resolve(cachedData[cachedId].data)
+      }
+
       options.successCallback(cachedData[cachedId].data);
     }
   };