ability to disable localStorage (#764)

This commit is contained in:
Alexey Nurgaliev 2024-02-05 21:36:19 +03:00 committed by GitHub
parent e703fab651
commit 29dff80731
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -3744,7 +3744,7 @@ class EmulatorJS {
}; };
} }
saveSettings() { saveSettings() {
if (!window.localStorage || !this.settingsLoaded) return; if (!window.localStorage || this.config.disableLocalStorage || !this.settingsLoaded) return;
const coreSpecific = { const coreSpecific = {
controlSettings: this.controls, controlSettings: this.controls,
settings: this.settings, settings: this.settings,
@ -3758,7 +3758,12 @@ class EmulatorJS {
localStorage.setItem("ejs-"+this.getCore()+"-settings", JSON.stringify(coreSpecific)); localStorage.setItem("ejs-"+this.getCore()+"-settings", JSON.stringify(coreSpecific));
} }
loadRewindEnabled() { loadRewindEnabled() {
if (!window.localStorage) return; if (!window.localStorage || this.config.disableLocalStorage) {
if (this.config.defaultOptions && this.config.defaultOptions.rewindEnabled) {
return this.config.defaultOptions.rewindEnabled === 'enabled';
}
return false;
}
let coreSpecific = localStorage.getItem("ejs-"+this.getCore()+"-settings"); let coreSpecific = localStorage.getItem("ejs-"+this.getCore()+"-settings");
try { try {
coreSpecific = JSON.parse(coreSpecific); coreSpecific = JSON.parse(coreSpecific);
@ -3772,7 +3777,7 @@ class EmulatorJS {
} }
} }
loadSettings() { loadSettings() {
if (!window.localStorage) return; if (!window.localStorage || this.config.disableLocalStorage) return;
this.settingsLoaded = true; this.settingsLoaded = true;
let ejs_settings = localStorage.getItem("ejs-settings"); let ejs_settings = localStorage.getItem("ejs-settings");
let coreSpecific = localStorage.getItem("ejs-"+this.getCore()+"-settings"); let coreSpecific = localStorage.getItem("ejs-"+this.getCore()+"-settings");

View file

@ -110,6 +110,7 @@
config.screenRecording = window.EJS_screenRecording; config.screenRecording = window.EJS_screenRecording;
config.externalFiles = window.EJS_externalFiles; config.externalFiles = window.EJS_externalFiles;
config.disableDatabases = window.EJS_disableDatabases; config.disableDatabases = window.EJS_disableDatabases;
config.disableLocalStorage = window.EJS_disableLocalStorage;
if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") { if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") {
try { try {