47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const SET_FULL_SCREEN = 'scratch-gui/mode/SET_FULL_SCREEN';
|
|
const SET_PLAYER = 'scratch-gui/mode/SET_PLAYER';
|
|
|
|
const initialState = {
|
|
showBranding: false,
|
|
isFullScreen: false,
|
|
isPlayerOnly: false,
|
|
hasEverEnteredEditor: true
|
|
};
|
|
|
|
const reducer = function (state, action) {
|
|
if (typeof state === 'undefined') state = initialState;
|
|
switch (action.type) {
|
|
case SET_FULL_SCREEN:
|
|
return Object.assign({}, state, {
|
|
isFullScreen: action.isFullScreen
|
|
});
|
|
case SET_PLAYER:
|
|
return Object.assign({}, state, {
|
|
isPlayerOnly: action.isPlayerOnly,
|
|
hasEverEnteredEditor: state.hasEverEnteredEditor || !action.isPlayerOnly
|
|
});
|
|
default:
|
|
return state;
|
|
}
|
|
};
|
|
|
|
const setFullScreen = function (isFullScreen) {
|
|
return {
|
|
type: SET_FULL_SCREEN,
|
|
isFullScreen: isFullScreen
|
|
};
|
|
};
|
|
const setPlayer = function (isPlayerOnly) {
|
|
return {
|
|
type: SET_PLAYER,
|
|
isPlayerOnly: isPlayerOnly
|
|
};
|
|
};
|
|
|
|
export {
|
|
reducer as default,
|
|
initialState as modeInitialState,
|
|
setFullScreen,
|
|
setPlayer
|
|
};
|