浏览代码

HUE-7956 [assist] Disable the browser cache when the TTL is set to 0

Johan Ahlen 7 年之前
父节点
当前提交
5ababfb
共有 1 个文件被更改,包括 13 次插入9 次删除
  1. 13 9
      desktop/core/src/desktop/static/desktop/js/dataCatalog.js

+ 13 - 9
desktop/core/src/desktop/static/desktop/js/dataCatalog.js

@@ -95,7 +95,7 @@ var DataCatalog = (function () {
    */
    */
   DataCatalog.prototype.updateStore = function (dataCatalogEntry) {
   DataCatalog.prototype.updateStore = function (dataCatalogEntry) {
     var self = this;
     var self = this;
-    if (!cacheEnabled) {
+    if (!cacheEnabled || CACHEABLE_TTL.default <= 0) {
       return $.Deferred().resolve().promise();
       return $.Deferred().resolve().promise();
     }
     }
     var deferred = $.Deferred();
     var deferred = $.Deferred();
@@ -520,10 +520,12 @@ var DataCatalog = (function () {
    */
    */
   DataCatalogEntry.prototype.saveLater = function () {
   DataCatalogEntry.prototype.saveLater = function () {
     var self = this;
     var self = this;
-    window.clearTimeout(self.saveTimeout);
-    self.saveTimeout = window.setTimeout(function () {
-      self.save();
-    }, 1000);
+    if (CACHEABLE_TTL.default > 0) {
+      window.clearTimeout(self.saveTimeout);
+      self.saveTimeout = window.setTimeout(function () {
+        self.save();
+      }, 1000);
+    }
   };
   };
 
 
   /**
   /**
@@ -1480,12 +1482,14 @@ var DataCatalog = (function () {
           silenceErrors: options && options.silenceErrors,
           silenceErrors: options && options.silenceErrors,
         }).done(deferred.resolve).fail(deferred.reject);
         }).done(deferred.resolve).fail(deferred.reject);
 
 
-        deferred.done(function (allTags) {
-          sharedDataCalogStore.setItem('hue.dataCatalog.allNavTags', { allTags: allTags, hueTimestamp: Date.now(), version: DATA_CATALOG_VERSION });
-        })
+        if (CACHEABLE_TTL.default > 0) {
+          deferred.done(function (allTags) {
+            sharedDataCalogStore.setItem('hue.dataCatalog.allNavTags', { allTags: allTags, hueTimestamp: Date.now(), version: DATA_CATALOG_VERSION });
+          })
+        }
       };
       };
 
 
-      if (!options || !options.refreshCache) {
+      if (CACHEABLE_TTL.default > 0 && (!options || !options.refreshCache)) {
         sharedDataCalogStore.getItem('hue.dataCatalog.allNavTags').then(function (storeEntry) {
         sharedDataCalogStore.getItem('hue.dataCatalog.allNavTags').then(function (storeEntry) {
           if (storeEntry && storeEntry.version === DATA_CATALOG_VERSION && (!storeEntry.hueTimestamp || (Date.now() - storeEntry.hueTimestamp) < CACHEABLE_TTL.default)) {
           if (storeEntry && storeEntry.version === DATA_CATALOG_VERSION && (!storeEntry.hueTimestamp || (Date.now() - storeEntry.hueTimestamp) < CACHEABLE_TTL.default)) {
             deferred.resolve(storeEntry.allTags);
             deferred.resolve(storeEntry.allTags);