Pārlūkot izejas kodu

HUE-6318 [editor] Fail gracefully when the browser cache is full

Johan Ahlen 8 gadi atpakaļ
vecāks
revīzija
44b1c67

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

@@ -184,14 +184,16 @@ var ApiHelper = (function () {
    */
   ApiHelper.prototype.setInTotalStorage = function(owner, id, value) {
     var self = this;
-    var cachedData = $.totalStorage("hue.user.settings." + self.getTotalStorageUserPrefix(owner)) || {};
-    if (typeof value !== 'undefined' && value !== null) {
-      cachedData[id] = value;
-      $.totalStorage("hue.user.settings." + self.getTotalStorageUserPrefix(owner), cachedData, { secure: window.location.protocol.indexOf('https') > -1 });
-    } else if (cachedData[id]) {
-      delete cachedData[id];
-      $.totalStorage("hue.user.settings." + self.getTotalStorageUserPrefix(owner), cachedData, { secure: window.location.protocol.indexOf('https') > -1 });
-    }
+    try {
+      var cachedData = $.totalStorage("hue.user.settings." + self.getTotalStorageUserPrefix(owner)) || {};
+      if (typeof value !== 'undefined' && value !== null) {
+        cachedData[id] = value;
+        $.totalStorage("hue.user.settings." + self.getTotalStorageUserPrefix(owner), cachedData, { secure: window.location.protocol.indexOf('https') > -1 });
+      } else if (cachedData[id]) {
+        delete cachedData[id];
+        $.totalStorage("hue.user.settings." + self.getTotalStorageUserPrefix(owner), cachedData, { secure: window.location.protocol.indexOf('https') > -1 });
+      }
+    } catch (e) {}
   };
 
   /**
@@ -1872,7 +1874,9 @@ var ApiHelper = (function () {
           timestamp: (new Date()).getTime(),
           data: data
         };
-        $.totalStorage(cacheIdentifier, cachedData);
+        try {
+          $.totalStorage(cacheIdentifier, cachedData);
+        } catch (e) {}
       });
     } else {
       if (options.promise) {