react-simple-chatbot
react-simple-chatbot copied to clipboard
SetupBot not working in safari private window
The setupbot doesn't work in the safari private window. It throws storage not available error. Is there any way to work for setupbot storin data in session storage and local storage?
Adding to this: this library does not work in chrome incognito windows or Brave Browser with shields down. It would ideally check whether localStorage is available, perhaps using code like the below. I don't think local storage/session storage should be required for the library to work. I assume it's a convenience feature for offline caching or similar?
function isStorageAvailable() {
let storage;
try {
storage = window['localStorage'];
const x = '__storage_test__';
storage.setItem(x, x);
storage.removeItem(x);
return true;
}
catch(e) {
return e instanceof DOMException && (
// everything except Firefox
e.code === 22 ||
// Firefox
e.code === 1014 ||
// test name field too, because code might not be present
// everything except Firefox
e.name === 'QuotaExceededError' ||
// Firefox
e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
// acknowledge QuotaExceededError only if there's something already stored
storage && storage.length !== 0;
}
}
export function safelyRetrieveLocalStorageItem(storageKey) {
if (!isStorageAvailable()) {
return;
}
try {
return localStorage.getItem(storageKey);
} catch (e) {
}
}
export function safelySetLocalStorageItem(storageKey, value) {
if (!isStorageAvailable()) {
return;
}
try {
return localStorage.setItem(storageKey, value);
} catch (e) {
}
}
Even if the cache option is false by default, it uses local storage to save the bot data.