From 1fce0f7c97d2f10f4b78798266e0db60e5e9e999 Mon Sep 17 00:00:00 2001 From: MatthieuLP Date: Wed, 14 Apr 2021 16:12:29 +0200 Subject: [PATCH] Fixes #1382 gracefully recovers from local storage write error --- admin/themes/default/js/LocalStorageCache.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/admin/themes/default/js/LocalStorageCache.js b/admin/themes/default/js/LocalStorageCache.js index 55e4b36fb..1442df10a 100644 --- a/admin/themes/default/js/LocalStorageCache.js +++ b/admin/themes/default/js/LocalStorageCache.js @@ -57,12 +57,18 @@ * @param data {mixed} */ LocalStorageCache.prototype.set = function(data) { - if (this.ready) { - this.storage[this.key] = JSON.stringify({ - timestamp: new Date().getTime(), - key: this.serverKey, - data: data - }); + try { + if (this.ready) { + this.storage[this.key] = JSON.stringify({ + timestamp: new Date().getTime(), + key: this.serverKey, + data: data + }); + } + } catch (e) { + console.log("Local storage error:"); + console.log(e); + console.log("Use of direct result from Piwigo API."); } };