From cf3757536ddcf92e3312419ba98cf8b9d9645562 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Tue, 5 Nov 2019 19:37:30 -0800 Subject: [PATCH] Remove the ability to persist state in the demo --- demo/js/index.js | 15 ++++----------- demo/js/indexedDB.js | 40 ---------------------------------------- package.json | 1 - yarn.lock | 11 ----------- 4 files changed, 4 insertions(+), 63 deletions(-) delete mode 100644 demo/js/indexedDB.js diff --git a/demo/js/index.js b/demo/js/index.js index da05fa8a..11667394 100644 --- a/demo/js/index.js +++ b/demo/js/index.js @@ -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( diff --git a/demo/js/indexedDB.js b/demo/js/indexedDB.js deleted file mode 100644 index 645af832..00000000 --- a/demo/js/indexedDB.js +++ /dev/null @@ -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)); -} diff --git a/package.json b/package.json index f6badeb8..a7468b3b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 067134e7..b3d3b2f1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"