diff --git a/index.html b/index.html index 9244d2e9..46004ccb 100755 --- a/index.html +++ b/index.html @@ -12,8 +12,6 @@ - - diff --git a/js/actionTypes.js b/js/actionTypes.js index e4a49ef0..b99df36c 100644 --- a/js/actionTypes.js +++ b/js/actionTypes.js @@ -63,3 +63,4 @@ export const UPDATE_WINDOW_POSITIONS = "UPDATE_WINDOW_POSITIONS"; export const CHANNEL_COUNT_CHANGED = "CHANNEL_COUNT_CHANGED"; export const WINDOW_SIZE_CHANGED = "WINDOW_SIZE_CHANGED"; export const TOGGLE_WINDOW_SHADE_MODE = "TOGGLE_WINDOW_SHADE_MODE"; +export const LOADED = "LOADED"; diff --git a/js/components/MainWindow/__snapshots__/index.test.js.snap b/js/components/MainWindow/__snapshots__/index.test.js.snap index b0e1848b..52beba0c 100644 --- a/js/components/MainWindow/__snapshots__/index.test.js.snap +++ b/js/components/MainWindow/__snapshots__/index.test.js.snap @@ -2,7 +2,7 @@ exports[`MainWindow renders to snapshot 1`] = `
{ }; } + const initialSkin = !skinUrl ? null : { url: skinUrl }; + const webamp = new Webamp({ + initialSkin, initialTracks, availableSkins: [ { url: base, name: "" }, diff --git a/js/reducers/display.js b/js/reducers/display.js index ee626707..263bb963 100644 --- a/js/reducers/display.js +++ b/js/reducers/display.js @@ -7,7 +7,8 @@ import { TOGGLE_DOUBLESIZE_MODE, TOGGLE_LLAMA_MODE, TOGGLE_VISUALIZER_STYLE, - SET_PLAYLIST_SCROLL_POSITION + SET_PLAYLIST_SCROLL_POSITION, + LOADED } from "../actionTypes"; const defaultDisplayState = { @@ -41,6 +42,11 @@ const display = (state = defaultDisplayState, action) => { return { ...state, working: true }; case CLOSE_WINAMP: return { ...state, closed: true }; + case LOADED: + return { + ...state, + loading: false + }; case SET_SKIN_DATA: return { ...state, diff --git a/js/webamp.js b/js/webamp.js index 018d36cb..e15ae127 100644 --- a/js/webamp.js +++ b/js/webamp.js @@ -22,10 +22,13 @@ import { CLOSE_WINAMP, MINIMIZE_WINAMP, ADD_GEN_WINDOW, - UPDATE_WINDOW_POSITIONS + UPDATE_WINDOW_POSITIONS, + LOADED } from "./actionTypes"; import Emitter from "./emitter"; +import "../css/base-skin.min.css"; + // Return a promise that resolves when the store matches a predicate. const storeHas = (store, predicate) => new Promise(resolve => { @@ -56,6 +59,7 @@ class Winamp { this.options = options; const { initialTracks, + initialSkin, avaliableSkins, // Old misspelled name availableSkins, enableHotkeys = false, @@ -96,7 +100,11 @@ class Winamp { this.store.dispatch({ type: NETWORK_DISCONNECTED }) ); - //this.store.dispatch(setSkinFromUrl(this.options.initialSkin.url)); + if (initialSkin) { + this.store.dispatch(setSkinFromUrl(initialSkin.url)); + } else { + this.store.dispatch({ type: LOADED }); + } if (initialTracks) { this.appendTracks(initialTracks); @@ -150,7 +158,7 @@ class Winamp { async renderWhenReady(node) { // Wait for the skin to load. - //await storeHas(this.store, state => !state.display.loading); + await storeHas(this.store, state => !state.display.loading); const genWindowComponents = {}; this.genWindows.forEach(w => {