Standardize feature flags, such as they are

This commit is contained in:
Jordan Eldredge 2017-08-18 17:14:34 -07:00
parent 969cc4239b
commit c3a3614c2c
4 changed files with 42 additions and 39 deletions

View file

@ -6,6 +6,7 @@ import { getTimeStr } from "../../utils";
import { STEP_MARQUEE } from "../../actionTypes";
import CharacterString from "../CharacterString";
import { noMarquee } from "../../config";
const CHAR_WIDTH = 5;
@ -74,7 +75,9 @@ class Marquee extends React.Component {
step();
}, 220);
};
step();
if (!noMarquee) {
step();
}
}
getText() {

6
js/config.js Normal file
View file

@ -0,0 +1,6 @@
const { hash } = window.location;
// Turn on the incomplete playlist window
export const playlistEnabled = hash.includes("playlist");
// Turn on the incomplete equalizer window
export const equalizerEnabled = hash.includes("equalizer");
export const noMarquee = hash.includes("!marquee");

View file

@ -13,13 +13,9 @@ import EqualizerWindow from "./components/EqualizerWindow";
import Winamp from "./winamp";
import Hotkeys from "./hotkeys";
import Skin from "./components/Skin";
import { equalizerEnabled, playlistEnabled } from "./config";
if (new Browser(window).isCompatible) {
const hash = window.location.hash;
// Turn on the incomplete playlist window
const playlist = hash.includes("playlist");
// Turn on the incomplete equalizer window
const equalizer = hash.includes("equalizer");
const winamp = Winamp;
const store = getStore(winamp);
@ -33,8 +29,8 @@ if (new Browser(window).isCompatible) {
</Skin>
<WindowManager>
<MainWindow fileInput={winamp.fileInput} mediaPlayer={winamp.media} />
{playlist && <PlaylistWindow />}
{equalizer && <EqualizerWindow fileInput={winamp.fileInput} />}
{playlistEnabled && <PlaylistWindow />}
{equalizerEnabled && <EqualizerWindow fileInput={winamp.fileInput} />}
</WindowManager>
</div>
</Provider>,

View file

@ -34,6 +34,7 @@ import {
UNSET_FOCUS,
UPDATE_TIME_ELAPSED
} from "./actionTypes";
import { equalizerEnabled } from "./config";
export const userInput = (state, action) => {
if (!state) {
@ -54,18 +55,17 @@ export const userInput = (state, action) => {
}
};
const windows = (state, action) => {
if (!state) {
return {
focused: WINDOWS.MAIN,
equalizer: false
};
}
const defaultWindowsState = {
focused: WINDOWS.MAIN,
equalizer: equalizerEnabled
};
const windows = (state = defaultWindowsState, action) => {
switch (action.type) {
case SET_FOCUSED_WINDOW:
return { ...state, focused: action.window };
case TOGGLE_EQUALIZER_WINDOW:
if (process.env.NODE_ENV === "production") {
if (!equalizerEnabled) {
return state;
}
return { ...state, equalizer: !state.equalizer };
@ -76,23 +76,22 @@ const windows = (state, action) => {
}
};
const display = (state, action) => {
if (!state) {
return {
doubled: false,
marqueeStep: 0,
loading: true,
llama: false,
closed: false,
shade: false,
equalizerShade: false,
working: false,
skinImages: {},
skinColors: null,
skinPlaylistStyle: {},
visualizerStyle: 2
};
}
const defaultDisplayState = {
doubled: false,
marqueeStep: 0,
loading: true,
llama: false,
closed: false,
shade: false,
equalizerShade: false,
working: false,
skinImages: {},
skinColors: null,
skinPlaylistStyle: {},
visualizerStyle: 2
};
const display = (state = defaultDisplayState, action) => {
switch (action.type) {
case TOGGLE_DOUBLESIZE_MODE:
return { ...state, doubled: !state.doubled };
@ -128,12 +127,11 @@ const display = (state, action) => {
}
};
const contextMenu = (state, action) => {
if (!state) {
return {
selected: false
};
}
const defaultContextMenuState = {
selected: false
};
const contextMenu = (state = defaultContextMenuState, action) => {
switch (action.type) {
case TOGGLE_CONTEXT_MENU:
return { ...state, selected: !state.selected };