add sound selector
This commit is contained in:
@@ -2,6 +2,7 @@ import {
|
||||
VISIT,
|
||||
LANGUAGE,
|
||||
RENDERER,
|
||||
SOUNDS,
|
||||
STATISTICS,
|
||||
PLATFORM,
|
||||
} from "../actions/types";
|
||||
@@ -20,6 +21,14 @@ const initialPlatform = () => {
|
||||
return getPlatform();
|
||||
};
|
||||
|
||||
const initialSounds = () => {
|
||||
if (window.localStorage.getItem("sounds")) {
|
||||
return window.localStorage.getItem("sounds");
|
||||
} else {
|
||||
return "off";
|
||||
}
|
||||
};
|
||||
|
||||
const getPlatform = () => {
|
||||
if (window.localStorage.getItem("platform")) {
|
||||
return JSON.parse(window.localStorage.getItem("platform"));
|
||||
@@ -62,6 +71,7 @@ const initialState = {
|
||||
pageVisits: 0, // detect if previous URL was
|
||||
language: initialLanguage(),
|
||||
renderer: initialRenderer(),
|
||||
sounds: initialSounds(),
|
||||
statistics: initialStatistics(),
|
||||
platform: initialPlatform(),
|
||||
};
|
||||
@@ -90,6 +100,12 @@ export default function foo(state = initialState, action) {
|
||||
...state,
|
||||
renderer: action.payload,
|
||||
};
|
||||
case SOUNDS:
|
||||
window.localStorage.setItem("sounds", action.payload);
|
||||
return {
|
||||
...state,
|
||||
sounds: action.payload,
|
||||
};
|
||||
case STATISTICS:
|
||||
window.localStorage.setItem("statistics", action.payload);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user