Remove the ability to persist state in the demo

This commit is contained in:
Jordan Eldredge 2019-11-05 19:37:30 -08:00
parent 46447cd24d
commit cf3757536d
4 changed files with 4 additions and 63 deletions

View File

@ -25,7 +25,6 @@ import {
} from "../../js/actionTypes";
import { loadFilesFromReferences } from "../../js/actionCreators";
import { bindToIndexedDB } from "./indexedDB";
import { getButterchurnOptions } from "./butterchurnOptions";
import dropboxFilePicker from "./dropboxFilePicker";
import availableSkins from "./avaliableSkins";
@ -54,8 +53,6 @@ const NOISY_ACTION_TYPES = new Set([
const MIN_MILKDROP_WIDTH = 725;
let screenshot = false;
let clearState = false;
let useState = false;
let skinUrl = configSkinUrl;
let library = false;
if ("URLSearchParams" in window) {
@ -69,8 +66,6 @@ if ("URLSearchParams" in window) {
skinUrl = base;
}
skinUrl = params.get("skinUrl") || skinUrl;
clearState = Boolean(params.get("clearState"));
useState = Boolean(params.get("useState"));
}
function supressDragAndDrop(e) {
@ -172,7 +167,9 @@ Raven.context(async () => {
requireJSZip: () =>
import(/* webpackChunkName: "jszip" */ "jszip/dist/jszip"),
requireMusicMetadata: () =>
import(/* webpackChunkName: "music-metadata-browser" */ "music-metadata-browser/dist/index"),
import(
/* webpackChunkName: "music-metadata-browser" */ "music-metadata-browser/dist/index"
),
__enableMediaLibrary: library,
__initialWindowLayout,
__initialState: screenshot ? screenshotInitialState : initialState,
@ -215,9 +212,7 @@ Raven.context(async () => {
document.title =
track == null
? DEFAULT_DOCUMENT_TITLE
: `${track.metaData.title} - ${
track.metaData.artist
} \u00B7 ${DEFAULT_DOCUMENT_TITLE}`;
: `${track.metaData.title} - ${track.metaData.artist} \u00B7 ${DEFAULT_DOCUMENT_TITLE}`;
});
enableMediaSession(webamp);
@ -236,8 +231,6 @@ Raven.context(async () => {
// Expose webamp instance for debugging and integration tests.
window.__webamp = webamp;
await bindToIndexedDB(webamp, clearState, useState);
await webamp.renderWhenReady(document.getElementById("app"));
ReactDOM.render(

View File

@ -1,40 +0,0 @@
import IdbKvStore from "idb-kv-store";
import { throttle } from "../../js/utils";
const LOCAL_STORAGE_KEY = "webamp_state";
export async function bindToIndexedDB(webamp, clearState, useState) {
if (!useState) {
return;
}
const localStore = new IdbKvStore("webamp_state_database");
if (clearState) {
try {
await localStore.clear();
} catch (e) {
console.log("Failed to clear our IndexeddB state", e);
}
}
let previousSerializedState = null;
try {
previousSerializedState = await localStore.get(LOCAL_STORAGE_KEY);
} catch (e) {
console.error("Failed to load the saved state from IndexedDB", e);
}
if (previousSerializedState != null) {
webamp.__loadSerializedState(previousSerializedState);
}
async function persist() {
const serializedState = webamp.__getSerializedState();
try {
await localStore.set(LOCAL_STORAGE_KEY, serializedState);
} catch (e) {
console.log("Failed to save our state to IndexedDB", e);
}
}
webamp.__onStateChange(throttle(persist, 1000));
}

View File

@ -104,7 +104,6 @@
"html-webpack-inline-svg-plugin": "^1.2.4",
"html-webpack-plugin": "^3.2.0",
"http-server": "^0.11.1",
"idb-kv-store": "^4.4.0",
"imagemin": "^6.1.0",
"imagemin-optipng": "^6.0.0",
"invariant": "^2.2.3",

View File

@ -5501,13 +5501,6 @@ icss-utils@^2.1.0:
dependencies:
postcss "^6.0.1"
idb-kv-store@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/idb-kv-store/-/idb-kv-store-4.4.0.tgz#22c56a8d5f90bd88f818a859db9c58627de278be"
dependencies:
inherits "^2.0.3"
promisize "^1.1.2"
ieee754@^1.1.4:
version "1.1.8"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"
@ -8746,10 +8739,6 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"
promisize@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/promisize/-/promisize-1.1.2.tgz#9b47e2cb2ae497eb1ebadc2c4191d64d15c949d1"
prompts@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.0.3.tgz#c5ccb324010b2e8f74752aadceeb57134c1d2522"