Language as window.language for access in pure function

This commit is contained in:
James Barnsley
2020-07-05 20:58:39 +12:00
parent 78ec0eff26
commit 1158fb7c2f
14 changed files with 17353 additions and 136 deletions

View File

@ -69,6 +69,13 @@ export function setWindowFocus(window_focus) {
};
}
export function setLanguage(language) {
return {
type: 'SET_LANGUAGE',
language,
};
}
export function hideContextMenu() {
return {
type: 'HIDE_CONTEXT_MENU',

View File

@ -3,9 +3,6 @@ import ReactGA from 'react-ga';
const uiActions = require('./actions.js');
const UIMiddleware = (function () {
/**
* The actual middleware inteceptor
* */
return (store) => (next) => (action) => {
switch (action.type) {
case 'MOPIDY_STATE':
@ -252,6 +249,12 @@ const UIMiddleware = (function () {
next(action);
break;
case 'SET_LANGUAGE':
const { language } = action;
window.language = language;
store.dispatch(uiActions.set({ language }));
break;
// This action is irrelevant to us, pass it on to the next middleware
default:
return next(action);