add generalReducer to store settings

This commit is contained in:
Delucse
2020-12-14 13:06:55 +01:00
parent 7d1d2409e4
commit e52e3943c1
14 changed files with 360 additions and 170 deletions
+22 -2
View File
@@ -1,8 +1,11 @@
import { VISIT } from '../actions/types';
import { VISIT, LANGUAGE, RENDERER, STATISTICS } from '../actions/types';
const initialState = {
pageVisits: 0 // detect if previous URL was
pageVisits: 0, // detect if previous URL was
language: 'de',
renderer: window.localStorage.getItem('renderer') || 'geras',
statistics: window.localStorage.getItem('statistics') === 'true' ? true : window.localStorage.getItem('statistics') === 'false' ? false : false
};
export default function(state = initialState, action){
@@ -12,6 +15,23 @@ export default function(state = initialState, action){
...state,
pageVisits: state.pageVisits += 1
};
case LANGUAGE:
return {
...state,
language: action.payload
};
case RENDERER:
window.localStorage.setItem('renderer', action.payload);
return {
...state,
renderer: action.payload
};
case STATISTICS:
window.localStorage.setItem('statistics', action.payload);
return {
...state,
statistics: action.payload
};
default:
return state;
}