From bb2934e24388932a5d1b28eb4a659c5e9906eda8 Mon Sep 17 00:00:00 2001 From: Chris Miceli Date: Sat, 5 Feb 2022 22:04:14 -0600 Subject: [PATCH] 1119 Privacy - Query Page and Dom.storage implement memory storage for functionality in case of no storage Signed-off-by: Chris Miceli --- scripts/pi-hole/js/utils.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/pi-hole/js/utils.js b/scripts/pi-hole/js/utils.js index 22ac3887f..a6af435d3 100644 --- a/scripts/pi-hole/js/utils.js +++ b/scripts/pi-hole/js/utils.js @@ -229,13 +229,20 @@ function setBsSelectDefaults() { }; } +var backupStorage = {}; function stateSaveCallback(itemName, data) { - localStorage.setItem(itemName, JSON.stringify(data)); + if (localStorage === null) { + backupStorage[itemName] = JSON.stringify(data); + } else { + localStorage.setItem(itemName, JSON.stringify(data)); + } } function stateLoadCallback(itemName) { // Receive previous state from client's local storage area - var data = localStorage ? localStorage.getItem(itemName) : null; + var data = + localStorage === null ? backupStorage[itemName] || null : localStorage.getItem(itemName); + // Return if not available if (data === null) { return null;