Make state serialization opt-in (for now)

This commit is contained in:
Jordan Eldredge 2018-09-20 06:50:08 -07:00
parent 3f1861d4f8
commit bef421ebed
2 changed files with 8 additions and 2 deletions

View File

@ -87,12 +87,14 @@ const MIN_MILKDROP_WIDTH = 725;
let screenshot = false;
let clearState = false;
let useState = false;
let skinUrl = configSkinUrl;
if ("URLSearchParams" in window) {
const params = new URLSearchParams(location.search);
screenshot = params.get("screenshot");
skinUrl = params.get("skinUrl") || skinUrl;
clearState = Boolean(params.get("clearState"));
useState = Boolean(params.get("useState"));
}
function supressDragAndDrop(e) {
@ -301,7 +303,7 @@ Raven.context(async () => {
// Expose webamp instance for debugging and integration tests.
window.__webamp = webamp;
await bindToIndexDB(webamp, clearState);
await bindToIndexDB(webamp, clearState, useState);
await webamp.renderWhenReady(document.getElementById("app"));
});

View File

@ -2,7 +2,7 @@ import IdbKvStore from "idb-kv-store";
import { throttle } from "./utils";
const LOCAL_STORAGE_KEY = "webamp_state";
export async function bindToIndexDB(webamp, clearState) {
export async function bindToIndexDB(webamp, clearState, useState) {
const localStore = new IdbKvStore("webamp_state_database");
if (clearState) {
@ -13,6 +13,10 @@ export async function bindToIndexDB(webamp, clearState) {
}
}
if (!useState) {
return;
}
let previousSerializedState = null;
try {
previousSerializedState = await localStore.get(LOCAL_STORAGE_KEY);