2021-09-09 21:51:18 +08:00
|
|
|
import React, { useReducer } from 'react';
|
|
|
|
import { createContext, useContextSelector } from 'use-context-selector';
|
2021-05-18 04:25:07 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2021-08-05 19:03:24 +08:00
|
|
|
import { ACTIONS } from '/imports/ui/components/layout/enums';
|
|
|
|
import DEFAULT_VALUES from '/imports/ui/components/layout/defaultValues';
|
2021-05-18 04:25:07 +08:00
|
|
|
import { INITIAL_INPUT_STATE, INITIAL_OUTPUT_STATE } from './initState';
|
2020-04-23 22:07:44 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
// variable to debug in console log
|
|
|
|
const debug = false;
|
2020-03-05 02:34:10 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const debugActions = (action, value) => {
|
|
|
|
const baseStyles = [
|
|
|
|
'color: #fff',
|
|
|
|
'background-color: #d64541',
|
|
|
|
'padding: 2px 4px',
|
|
|
|
'border-radius: 2px',
|
|
|
|
].join(';');
|
|
|
|
return debug && console.log(`%c${action}`, baseStyles, value);
|
|
|
|
};
|
|
|
|
|
|
|
|
const providerPropTypes = {
|
|
|
|
children: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(PropTypes.node),
|
|
|
|
PropTypes.node,
|
|
|
|
]).isRequired,
|
|
|
|
};
|
|
|
|
|
2021-09-09 21:51:18 +08:00
|
|
|
const LayoutContextSelector = createContext();
|
2021-05-18 04:25:07 +08:00
|
|
|
|
|
|
|
const initState = {
|
|
|
|
deviceType: null,
|
2021-07-26 22:03:31 +08:00
|
|
|
isRTL: false,
|
2021-05-18 04:25:07 +08:00
|
|
|
layoutType: DEFAULT_VALUES.layoutType,
|
2021-06-19 02:32:46 +08:00
|
|
|
fontSize: DEFAULT_VALUES.fontSize,
|
2021-05-20 22:36:26 +08:00
|
|
|
idChatOpen: DEFAULT_VALUES.idChatOpen,
|
2021-07-13 03:47:06 +08:00
|
|
|
fullscreen: {
|
|
|
|
element: '',
|
|
|
|
group: '',
|
2020-03-05 02:34:10 +08:00
|
|
|
},
|
2021-05-18 04:25:07 +08:00
|
|
|
input: INITIAL_INPUT_STATE,
|
|
|
|
output: INITIAL_OUTPUT_STATE,
|
2020-03-05 02:34:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const reducer = (state, action) => {
|
2021-05-18 04:25:07 +08:00
|
|
|
debugActions(action.type, action.value);
|
2020-03-05 02:34:10 +08:00
|
|
|
switch (action.type) {
|
2022-02-11 22:30:35 +08:00
|
|
|
|
2022-02-05 02:08:19 +08:00
|
|
|
case ACTIONS.SET_FOCUSED_CAMERA_ID: {
|
2022-02-11 22:30:35 +08:00
|
|
|
const { cameraDock } = state.input;
|
|
|
|
const { focusedId } = cameraDock;
|
|
|
|
|
2022-02-05 02:08:19 +08:00
|
|
|
if (focusedId === action.value) return state;
|
2022-02-11 22:30:35 +08:00
|
|
|
|
2022-02-05 02:08:19 +08:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
2022-02-11 22:30:35 +08:00
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
focusedId: action.value,
|
2022-04-15 03:22:21 +08:00
|
|
|
},
|
2022-02-05 02:08:19 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_LAYOUT_INPUT: {
|
|
|
|
if (state.input === action.value) return state;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: action.value,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
case ACTIONS.SET_AUTO_ARRANGE_LAYOUT: {
|
|
|
|
const { autoarrAngeLayout } = state.input;
|
|
|
|
if (autoarrAngeLayout === action.value) return state;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
autoarrAngeLayout: action.value,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-26 22:03:31 +08:00
|
|
|
case ACTIONS.SET_IS_RTL: {
|
|
|
|
const { isRTL } = state;
|
|
|
|
if (isRTL === action.value) return state;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isRTL: action.value,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// LAYOUT TYPE
|
|
|
|
// using to load a diferent layout manager
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_LAYOUT_TYPE: {
|
|
|
|
const { layoutType } = state.input;
|
|
|
|
if (layoutType === action.value) return state;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
layoutType: action.value,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-06-19 02:32:46 +08:00
|
|
|
// FONT SIZE
|
|
|
|
case ACTIONS.SET_FONT_SIZE: {
|
|
|
|
const { fontSize } = state;
|
|
|
|
if (fontSize === action.value) return state;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
fontSize: action.value,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// ID CHAT open in sidebar content panel
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_ID_CHAT_OPEN: {
|
|
|
|
if (state.idChatOpen === action.value) return state;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
idChatOpen: action.value,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// DEVICE
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_DEVICE_TYPE: {
|
|
|
|
const { deviceType } = state;
|
|
|
|
if (deviceType === action.value) return state;
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
deviceType: action.value,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// BROWSER
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_BROWSER_SIZE: {
|
|
|
|
const { width, height } = action.value;
|
|
|
|
const { browser } = state.input;
|
|
|
|
if (browser.width === width
|
|
|
|
&& browser.height === height) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
browser: {
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-12 21:22:26 +08:00
|
|
|
// BANNER BAR
|
|
|
|
case ACTIONS.SET_HAS_BANNER_BAR: {
|
|
|
|
const { bannerBar } = state.input;
|
|
|
|
if (bannerBar.hasBanner === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
bannerBar: {
|
|
|
|
...bannerBar,
|
|
|
|
hasBanner: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-13 00:24:53 +08:00
|
|
|
// NOTIFICATIONS BAR
|
|
|
|
case ACTIONS.SET_HAS_NOTIFICATIONS_BAR: {
|
|
|
|
const { notificationsBar } = state.input;
|
|
|
|
if (notificationsBar.hasNotification === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
notificationsBar: {
|
|
|
|
...notificationsBar,
|
|
|
|
hasNotification: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// NAV BAR
|
2023-11-28 22:45:12 +08:00
|
|
|
|
|
|
|
case ACTIONS.SET_HAS_NAVBAR: {
|
|
|
|
const { navBar } = state.input;
|
|
|
|
if (navBar.hasNavBar === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
navBar: {
|
|
|
|
...navBar,
|
|
|
|
hasNavBar: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_NAVBAR_OUTPUT: {
|
|
|
|
const {
|
|
|
|
display, width, height, top, left, tabOrder, zIndex,
|
|
|
|
} = action.value;
|
|
|
|
const { navBar } = state.output;
|
|
|
|
if (navBar.display === display
|
|
|
|
&& navBar.width === width
|
|
|
|
&& navBar.height === height
|
|
|
|
&& navBar.top === top
|
|
|
|
&& navBar.left === left
|
|
|
|
&& navBar.zIndex === zIndex
|
|
|
|
&& navBar.tabOrder === tabOrder) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
navBar: {
|
|
|
|
...navBar,
|
|
|
|
display,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
top,
|
|
|
|
left,
|
|
|
|
tabOrder,
|
|
|
|
zIndex,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// ACTION BAR
|
2023-11-28 22:45:12 +08:00
|
|
|
case ACTIONS.SET_HAS_ACTIONBAR: {
|
|
|
|
const { actionBar } = state.input;
|
|
|
|
if (actionBar.hasActionBar === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
actionBar: {
|
|
|
|
...actionBar,
|
|
|
|
hasActionBar: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_ACTIONBAR_OUTPUT: {
|
|
|
|
const {
|
2021-07-22 22:04:38 +08:00
|
|
|
display, width, height, innerHeight, top, left, padding, tabOrder, zIndex,
|
2021-05-18 04:25:07 +08:00
|
|
|
} = action.value;
|
|
|
|
const { actionBar } = state.output;
|
|
|
|
if (actionBar.display === display
|
|
|
|
&& actionBar.width === width
|
|
|
|
&& actionBar.height === height
|
2021-07-22 22:04:38 +08:00
|
|
|
&& actionBar.innerHeight === innerHeight
|
2021-05-18 04:25:07 +08:00
|
|
|
&& actionBar.top === top
|
|
|
|
&& actionBar.left === left
|
2021-07-22 22:04:38 +08:00
|
|
|
&& actionBar.padding === padding
|
2021-05-18 04:25:07 +08:00
|
|
|
&& actionBar.zIndex === zIndex
|
|
|
|
&& actionBar.tabOrder === tabOrder) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
actionBar: {
|
|
|
|
...actionBar,
|
|
|
|
display,
|
|
|
|
width,
|
|
|
|
height,
|
2021-07-22 22:04:38 +08:00
|
|
|
innerHeight,
|
2021-05-18 04:25:07 +08:00
|
|
|
top,
|
|
|
|
left,
|
2021-07-22 22:04:38 +08:00
|
|
|
padding,
|
2021-05-18 04:25:07 +08:00
|
|
|
tabOrder,
|
|
|
|
zIndex,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-08-16 21:38:39 +08:00
|
|
|
// CAPTIONS
|
|
|
|
case ACTIONS.SET_CAPTIONS_OUTPUT: {
|
|
|
|
const {
|
2021-08-17 22:20:26 +08:00
|
|
|
left, right, maxWidth,
|
2021-08-16 21:38:39 +08:00
|
|
|
} = action.value;
|
|
|
|
const { captions } = state.output;
|
|
|
|
if (captions.left === left
|
|
|
|
&& captions.right === right
|
2021-08-17 22:20:26 +08:00
|
|
|
&& captions.maxWidth === maxWidth) {
|
2021-08-16 21:38:39 +08:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
captions: {
|
|
|
|
...captions,
|
|
|
|
left,
|
|
|
|
right,
|
2021-08-17 22:20:26 +08:00
|
|
|
maxWidth,
|
2021-08-16 21:38:39 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// SIDEBAR NAVIGATION
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_SIDEBAR_NAVIGATION_IS_OPEN: {
|
|
|
|
const { sidebarNavigation } = state.input;
|
|
|
|
if (sidebarNavigation.isOpen === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
sidebarNavigation: {
|
|
|
|
...sidebarNavigation,
|
|
|
|
isOpen: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-19 22:51:31 +08:00
|
|
|
case ACTIONS.SET_SIDEBAR_NAVIGATION_PANEL: {
|
|
|
|
const { sidebarNavigation } = state.input;
|
|
|
|
if (sidebarNavigation.sidebarNavPanel === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
sidebarNavigation: {
|
|
|
|
...sidebarNavigation,
|
|
|
|
sidebarNavPanel: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_SIDEBAR_NAVIGATION_SIZE: {
|
|
|
|
const { width, browserWidth } = action.value;
|
|
|
|
const { sidebarNavigation } = state.input;
|
|
|
|
if (sidebarNavigation.width === width
|
|
|
|
&& sidebarNavigation.browserWidth === browserWidth) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
sidebarNavigation: {
|
|
|
|
...sidebarNavigation,
|
|
|
|
width,
|
|
|
|
browserWidth,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case ACTIONS.SET_SIDEBAR_NAVIGATION_OUTPUT: {
|
|
|
|
const {
|
|
|
|
display,
|
|
|
|
minWidth,
|
|
|
|
width,
|
|
|
|
maxWidth,
|
|
|
|
minHeight,
|
|
|
|
height,
|
|
|
|
maxHeight,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-05-18 04:25:07 +08:00
|
|
|
tabOrder,
|
|
|
|
isResizable,
|
|
|
|
zIndex,
|
|
|
|
} = action.value;
|
|
|
|
const { sidebarNavigation } = state.output;
|
|
|
|
if (sidebarNavigation.display === display
|
2021-09-10 03:17:31 +08:00
|
|
|
&& sidebarNavigation.minWidth === minWidth
|
|
|
|
&& sidebarNavigation.maxWidth === maxWidth
|
2021-05-18 04:25:07 +08:00
|
|
|
&& sidebarNavigation.width === width
|
2021-09-10 03:17:31 +08:00
|
|
|
&& sidebarNavigation.minHeight === minHeight
|
2021-05-18 04:25:07 +08:00
|
|
|
&& sidebarNavigation.height === height
|
2021-09-10 03:17:31 +08:00
|
|
|
&& sidebarNavigation.maxHeight === maxHeight
|
2021-05-18 04:25:07 +08:00
|
|
|
&& sidebarNavigation.top === top
|
|
|
|
&& sidebarNavigation.left === left
|
2021-07-27 04:28:05 +08:00
|
|
|
&& sidebarNavigation.right === right
|
2021-05-18 04:25:07 +08:00
|
|
|
&& sidebarNavigation.tabOrder === tabOrder
|
|
|
|
&& sidebarNavigation.zIndex === zIndex
|
|
|
|
&& sidebarNavigation.isResizable === isResizable) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-04-23 22:07:44 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
sidebarNavigation: {
|
|
|
|
...sidebarNavigation,
|
|
|
|
display,
|
|
|
|
minWidth,
|
|
|
|
width,
|
|
|
|
maxWidth,
|
|
|
|
minHeight,
|
|
|
|
height,
|
|
|
|
maxHeight,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-05-18 04:25:07 +08:00
|
|
|
tabOrder,
|
|
|
|
isResizable,
|
|
|
|
zIndex,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case ACTIONS.SET_SIDEBAR_NAVIGATION_RESIZABLE_EDGE: {
|
|
|
|
const {
|
|
|
|
top, right, bottom, left,
|
|
|
|
} = action.value;
|
|
|
|
const { sidebarNavigation } = state.output;
|
|
|
|
if (sidebarNavigation.resizableEdge.top === top
|
|
|
|
&& sidebarNavigation.resizableEdge.right === right
|
|
|
|
&& sidebarNavigation.resizableEdge.bottom === bottom
|
|
|
|
&& sidebarNavigation.resizableEdge.left === left) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
sidebarNavigation: {
|
|
|
|
...sidebarNavigation,
|
|
|
|
resizableEdge: {
|
|
|
|
top,
|
|
|
|
right,
|
|
|
|
bottom,
|
|
|
|
left,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-04-23 22:07:44 +08:00
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// SIDEBAR CONTENT
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_SIDEBAR_CONTENT_IS_OPEN: {
|
2021-12-21 02:24:30 +08:00
|
|
|
const { sidebarContent, sidebarNavigation } = state.input;
|
2021-05-18 04:25:07 +08:00
|
|
|
if (sidebarContent.isOpen === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2021-12-21 02:24:30 +08:00
|
|
|
// When opening content sidebar, the navigation sidebar should be opened as well
|
|
|
|
if (action.value === true) sidebarNavigation.isOpen = true;
|
2020-06-16 23:20:24 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
2021-12-21 02:24:30 +08:00
|
|
|
sidebarNavigation,
|
2021-05-18 04:25:07 +08:00
|
|
|
sidebarContent: {
|
|
|
|
...sidebarContent,
|
|
|
|
isOpen: action.value,
|
|
|
|
},
|
|
|
|
},
|
2020-06-16 23:20:24 +08:00
|
|
|
};
|
|
|
|
}
|
2021-05-19 22:51:31 +08:00
|
|
|
case ACTIONS.SET_SIDEBAR_CONTENT_PANEL: {
|
|
|
|
const { sidebarContent } = state.input;
|
|
|
|
if (sidebarContent.sidebarContentPanel === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-06-05 07:01:17 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-19 22:51:31 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
sidebarContent: {
|
|
|
|
...sidebarContent,
|
|
|
|
sidebarContentPanel: action.value,
|
|
|
|
},
|
|
|
|
},
|
2020-06-05 07:01:17 +08:00
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_SIDEBAR_CONTENT_SIZE: {
|
2021-07-13 03:47:06 +08:00
|
|
|
const {
|
|
|
|
width,
|
|
|
|
browserWidth,
|
|
|
|
height,
|
|
|
|
browserHeight,
|
|
|
|
} = action.value;
|
2021-05-18 04:25:07 +08:00
|
|
|
const { sidebarContent } = state.input;
|
|
|
|
if (sidebarContent.width === width
|
2021-06-29 21:31:44 +08:00
|
|
|
&& sidebarContent.browserWidth === browserWidth
|
|
|
|
&& sidebarContent.height === height
|
|
|
|
&& sidebarContent.browserHeight === browserHeight) {
|
2021-05-18 04:25:07 +08:00
|
|
|
return state;
|
|
|
|
}
|
2020-03-25 20:52:23 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
sidebarContent: {
|
|
|
|
...sidebarContent,
|
|
|
|
width,
|
|
|
|
browserWidth,
|
2021-06-29 21:31:44 +08:00
|
|
|
height,
|
|
|
|
browserHeight,
|
2021-05-18 04:25:07 +08:00
|
|
|
},
|
2020-03-25 20:52:23 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_SIDEBAR_CONTENT_OUTPUT: {
|
|
|
|
const {
|
|
|
|
display,
|
|
|
|
minWidth,
|
|
|
|
width,
|
|
|
|
maxWidth,
|
|
|
|
minHeight,
|
|
|
|
height,
|
|
|
|
maxHeight,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-05-18 04:25:07 +08:00
|
|
|
currentPanelType,
|
|
|
|
tabOrder,
|
|
|
|
isResizable,
|
|
|
|
zIndex,
|
|
|
|
} = action.value;
|
|
|
|
const { sidebarContent } = state.output;
|
|
|
|
if (sidebarContent.display === display
|
|
|
|
&& sidebarContent.minWidth === minWidth
|
|
|
|
&& sidebarContent.width === width
|
|
|
|
&& sidebarContent.maxWidth === maxWidth
|
|
|
|
&& sidebarContent.minHeight === minHeight
|
|
|
|
&& sidebarContent.height === height
|
|
|
|
&& sidebarContent.maxHeight === maxHeight
|
|
|
|
&& sidebarContent.top === top
|
|
|
|
&& sidebarContent.left === left
|
2021-07-27 04:28:05 +08:00
|
|
|
&& sidebarContent.right === right
|
2021-05-18 04:25:07 +08:00
|
|
|
&& sidebarContent.tabOrder === tabOrder
|
|
|
|
&& sidebarContent.zIndex === zIndex
|
|
|
|
&& sidebarContent.isResizable === isResizable) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-04-23 22:07:44 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
sidebarContent: {
|
|
|
|
...sidebarContent,
|
|
|
|
display,
|
|
|
|
minWidth,
|
|
|
|
width,
|
|
|
|
maxWidth,
|
|
|
|
minHeight,
|
|
|
|
height,
|
|
|
|
maxHeight,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-05-18 04:25:07 +08:00
|
|
|
currentPanelType,
|
|
|
|
tabOrder,
|
|
|
|
isResizable,
|
|
|
|
zIndex,
|
|
|
|
},
|
2020-04-23 22:07:44 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_SIDEBAR_CONTENT_RESIZABLE_EDGE: {
|
|
|
|
const {
|
|
|
|
top, right, bottom, left,
|
|
|
|
} = action.value;
|
|
|
|
const { sidebarContent } = state.output;
|
|
|
|
if (sidebarContent.resizableEdge.top === top
|
|
|
|
&& sidebarContent.resizableEdge.right === right
|
|
|
|
&& sidebarContent.resizableEdge.bottom === bottom
|
|
|
|
&& sidebarContent.resizableEdge.left === left) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-03-05 02:34:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
sidebarContent: {
|
|
|
|
...sidebarContent,
|
|
|
|
resizableEdge: {
|
|
|
|
top,
|
|
|
|
right,
|
|
|
|
bottom,
|
|
|
|
left,
|
|
|
|
},
|
|
|
|
},
|
2020-03-05 02:34:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// MEDIA
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_MEDIA_AREA_SIZE: {
|
|
|
|
const { width, height } = action.value;
|
|
|
|
const { mediaArea } = state.output;
|
|
|
|
if (mediaArea.width === width
|
|
|
|
&& mediaArea.height === height) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
mediaArea: {
|
|
|
|
...mediaArea,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// WEBCAMS
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_NUM_CAMERAS: {
|
|
|
|
const { cameraDock } = state.input;
|
|
|
|
if (cameraDock.numCameras === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-03-05 02:34:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
numCameras: action.value,
|
|
|
|
},
|
2020-03-05 02:34:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_CAMERA_DOCK_IS_DRAGGING: {
|
|
|
|
const { cameraDock } = state.input;
|
|
|
|
if (cameraDock.isDragging === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-06-20 13:46:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
isDragging: action.value,
|
|
|
|
},
|
2020-06-20 13:46:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-07-13 03:47:06 +08:00
|
|
|
case ACTIONS.SET_CAMERA_DOCK_IS_RESIZING: {
|
|
|
|
const { cameraDock } = state.input;
|
|
|
|
if (cameraDock.isResizing === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-06-20 13:46:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-07-13 03:47:06 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
isResizing: action.value,
|
|
|
|
},
|
2020-06-20 13:46:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_CAMERA_DOCK_POSITION: {
|
|
|
|
const { cameraDock } = state.input;
|
|
|
|
if (cameraDock.position === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-06-20 13:46:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
position: action.value,
|
|
|
|
},
|
2020-06-20 13:46:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_CAMERA_DOCK_SIZE: {
|
|
|
|
const {
|
|
|
|
width, height, browserWidth, browserHeight,
|
|
|
|
} = action.value;
|
|
|
|
const { cameraDock } = state.input;
|
|
|
|
if (cameraDock.width === width
|
|
|
|
&& cameraDock.height === height
|
|
|
|
&& cameraDock.browserWidth === browserWidth
|
|
|
|
&& cameraDock.browserHeight === browserHeight) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-06-20 13:46:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
browserWidth,
|
|
|
|
browserHeight,
|
|
|
|
},
|
2020-06-20 13:46:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-07-13 03:47:06 +08:00
|
|
|
case ACTIONS.SET_CAMERA_DOCK_OPTIMAL_GRID_SIZE: {
|
|
|
|
const { width, height } = action.value;
|
|
|
|
const { cameraDock } = state.input;
|
|
|
|
const { cameraOptimalGridSize } = cameraDock;
|
|
|
|
if (cameraOptimalGridSize.width === width
|
|
|
|
&& cameraOptimalGridSize.height === height) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-06-20 13:46:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-07-13 03:47:06 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
cameraOptimalGridSize: {
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
},
|
|
|
|
},
|
2020-06-20 13:46:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_CAMERA_DOCK_OUTPUT: {
|
|
|
|
const {
|
|
|
|
display,
|
2021-07-13 20:56:39 +08:00
|
|
|
position,
|
2021-05-18 04:25:07 +08:00
|
|
|
minWidth,
|
|
|
|
width,
|
|
|
|
maxWidth,
|
2021-08-06 00:24:37 +08:00
|
|
|
presenterMaxWidth,
|
2021-05-18 04:25:07 +08:00
|
|
|
minHeight,
|
|
|
|
height,
|
|
|
|
maxHeight,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-05-18 04:25:07 +08:00
|
|
|
tabOrder,
|
|
|
|
isDraggable,
|
2021-07-13 03:47:06 +08:00
|
|
|
resizableEdge,
|
2021-05-18 04:25:07 +08:00
|
|
|
zIndex,
|
2022-02-11 22:30:35 +08:00
|
|
|
focusedId,
|
2021-05-18 04:25:07 +08:00
|
|
|
} = action.value;
|
|
|
|
const { cameraDock } = state.output;
|
|
|
|
if (cameraDock.display === display
|
2021-07-13 20:56:39 +08:00
|
|
|
&& cameraDock.position === position
|
2021-05-18 04:25:07 +08:00
|
|
|
&& cameraDock.width === width
|
2021-08-06 00:24:37 +08:00
|
|
|
&& cameraDock.maxWidth === maxWidth
|
|
|
|
&& cameraDock.presenterMaxWidth === presenterMaxWidth
|
2021-05-18 04:25:07 +08:00
|
|
|
&& cameraDock.height === height
|
|
|
|
&& cameraDock.maxHeight === maxHeight
|
|
|
|
&& cameraDock.top === top
|
|
|
|
&& cameraDock.left === left
|
2021-07-27 04:28:05 +08:00
|
|
|
&& cameraDock.right === right
|
2021-05-18 04:25:07 +08:00
|
|
|
&& cameraDock.tabOrder === tabOrder
|
|
|
|
&& cameraDock.isDraggable === isDraggable
|
|
|
|
&& cameraDock.zIndex === zIndex
|
2022-02-11 22:30:35 +08:00
|
|
|
&& cameraDock.resizableEdge === resizableEdge
|
|
|
|
&& cameraDock.focusedId === focusedId) {
|
2021-05-18 04:25:07 +08:00
|
|
|
return state;
|
|
|
|
}
|
2020-04-23 22:07:44 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
display,
|
2021-07-13 20:56:39 +08:00
|
|
|
position,
|
2021-05-18 04:25:07 +08:00
|
|
|
minWidth,
|
|
|
|
width,
|
|
|
|
maxWidth,
|
2021-08-06 00:24:37 +08:00
|
|
|
presenterMaxWidth,
|
2021-05-18 04:25:07 +08:00
|
|
|
minHeight,
|
|
|
|
height,
|
|
|
|
maxHeight,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-05-18 04:25:07 +08:00
|
|
|
tabOrder,
|
|
|
|
isDraggable,
|
2021-07-13 03:47:06 +08:00
|
|
|
resizableEdge,
|
2021-05-18 04:25:07 +08:00
|
|
|
zIndex,
|
2022-02-11 22:30:35 +08:00
|
|
|
focusedId,
|
2021-05-18 04:25:07 +08:00
|
|
|
},
|
|
|
|
},
|
2020-04-23 22:07:44 +08:00
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_CAMERA_DOCK_IS_DRAGGABLE: {
|
|
|
|
const { cameraDock } = state.output;
|
|
|
|
if (cameraDock.isDraggable === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-03-05 02:34:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
cameraDock: {
|
|
|
|
...cameraDock,
|
|
|
|
isDraggable: action.value,
|
|
|
|
},
|
2020-03-05 02:34:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// WEBCAMS DROP AREAS
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_DROP_AREAS: {
|
|
|
|
const { dropZoneAreas } = state.output;
|
|
|
|
if (dropZoneAreas === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-06-16 23:20:24 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
dropZoneAreas: action.value,
|
2020-06-16 23:20:24 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// PRESENTATION
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_PRESENTATION_IS_OPEN: {
|
|
|
|
const { presentation } = state.input;
|
|
|
|
if (presentation.isOpen === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-05-01 06:18:03 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
presentation: {
|
|
|
|
...presentation,
|
|
|
|
isOpen: action.value,
|
|
|
|
},
|
|
|
|
},
|
2020-05-01 06:18:03 +08:00
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_PRESENTATION_SLIDES_LENGTH: {
|
|
|
|
const { presentation } = state.input;
|
|
|
|
if (presentation.slidesLength === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-05-01 06:18:03 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
presentation: {
|
|
|
|
...presentation,
|
|
|
|
slidesLength: action.value,
|
|
|
|
},
|
|
|
|
},
|
2020-05-01 06:18:03 +08:00
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_PRESENTATION_NUM_CURRENT_SLIDE: {
|
|
|
|
const { presentation } = state.input;
|
|
|
|
if (presentation.currentSlide.num === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-04-23 22:07:44 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
presentation: {
|
|
|
|
...presentation,
|
|
|
|
currentSlide: {
|
|
|
|
...presentation.currentSlide,
|
|
|
|
num: action.value,
|
|
|
|
},
|
|
|
|
},
|
2020-04-23 22:07:44 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_PRESENTATION_CURRENT_SLIDE_SIZE: {
|
|
|
|
const { width, height } = action.value;
|
|
|
|
const { presentation } = state.input;
|
|
|
|
const { currentSlide } = presentation;
|
|
|
|
if (currentSlide.size.width === width
|
|
|
|
&& currentSlide.size.height === height) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-03-05 02:34:10 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
presentation: {
|
|
|
|
...presentation,
|
|
|
|
currentSlide: {
|
|
|
|
...currentSlide,
|
|
|
|
size: {
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-05 02:34:10 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_PRESENTATION_RESIZABLE_EDGE: {
|
|
|
|
const {
|
|
|
|
top, right, bottom, left,
|
|
|
|
} = action.value;
|
|
|
|
const { presentation } = state.output;
|
|
|
|
const { resizableEdge } = presentation;
|
|
|
|
if (resizableEdge.top === top
|
|
|
|
&& resizableEdge.right === right
|
|
|
|
&& resizableEdge.bottom === bottom
|
|
|
|
&& resizableEdge.left === left) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-03-25 20:52:23 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
presentation: {
|
|
|
|
...presentation,
|
|
|
|
resizableEdge: {
|
|
|
|
top,
|
|
|
|
right,
|
|
|
|
bottom,
|
|
|
|
left,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-25 20:52:23 +08:00
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_PRESENTATION_SIZE: {
|
|
|
|
const {
|
|
|
|
width, height, browserWidth, browserHeight,
|
|
|
|
} = action.value;
|
|
|
|
const { presentation } = state.input;
|
|
|
|
if (presentation.width === width
|
|
|
|
&& presentation.height === height
|
|
|
|
&& presentation.browserWidth === browserWidth
|
|
|
|
&& presentation.browserHeight === browserHeight) {
|
|
|
|
return state;
|
|
|
|
}
|
2020-04-23 22:07:44 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
presentation: {
|
|
|
|
...presentation,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
browserWidth,
|
|
|
|
browserHeight,
|
|
|
|
},
|
|
|
|
},
|
2020-04-23 22:07:44 +08:00
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_PRESENTATION_OUTPUT: {
|
|
|
|
const {
|
|
|
|
display,
|
|
|
|
minWidth,
|
|
|
|
width,
|
|
|
|
maxWidth,
|
|
|
|
minHeight,
|
|
|
|
height,
|
|
|
|
maxHeight,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-05-18 04:25:07 +08:00
|
|
|
tabOrder,
|
|
|
|
isResizable,
|
|
|
|
zIndex,
|
|
|
|
} = action.value;
|
|
|
|
const { presentation } = state.output;
|
|
|
|
if (presentation.display === display
|
|
|
|
&& presentation.minWidth === minWidth
|
|
|
|
&& presentation.width === width
|
|
|
|
&& presentation.maxWidth === maxWidth
|
|
|
|
&& presentation.minHeight === minHeight
|
|
|
|
&& presentation.height === height
|
|
|
|
&& presentation.maxHeight === maxHeight
|
|
|
|
&& presentation.top === top
|
|
|
|
&& presentation.left === left
|
2021-07-27 04:28:05 +08:00
|
|
|
&& presentation.right === right
|
2021-05-18 04:25:07 +08:00
|
|
|
&& presentation.tabOrder === tabOrder
|
|
|
|
&& presentation.zIndex === zIndex
|
|
|
|
&& presentation.isResizable === isResizable) {
|
|
|
|
return state;
|
|
|
|
}
|
2021-02-24 01:04:00 +08:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-18 04:25:07 +08:00
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
presentation: {
|
|
|
|
...presentation,
|
|
|
|
display,
|
|
|
|
minWidth,
|
|
|
|
width,
|
|
|
|
maxWidth,
|
|
|
|
minHeight,
|
|
|
|
height,
|
|
|
|
maxHeight,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-05-18 04:25:07 +08:00
|
|
|
tabOrder,
|
|
|
|
isResizable,
|
|
|
|
zIndex,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-06 00:52:25 +08:00
|
|
|
// FULLSCREEN
|
|
|
|
case ACTIONS.SET_FULLSCREEN_ELEMENT: {
|
2021-07-13 03:47:06 +08:00
|
|
|
const { fullscreen } = state;
|
|
|
|
if (fullscreen.element === action.value.element
|
|
|
|
&& fullscreen.group === action.value.group) {
|
2021-07-06 00:52:25 +08:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
2021-07-13 03:47:06 +08:00
|
|
|
fullscreen: {
|
|
|
|
element: action.value.element,
|
|
|
|
group: action.value.group,
|
2021-07-06 00:52:25 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// SCREEN SHARE
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_HAS_SCREEN_SHARE: {
|
|
|
|
const { screenShare } = state.input;
|
|
|
|
if (screenShare.hasScreenShare === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
screenShare: {
|
|
|
|
...screenShare,
|
|
|
|
hasScreenShare: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case ACTIONS.SET_SCREEN_SHARE_SIZE: {
|
|
|
|
const {
|
|
|
|
width, height, browserWidth, browserHeight,
|
|
|
|
} = action.value;
|
|
|
|
const { screenShare } = state.input;
|
|
|
|
if (screenShare.width === width
|
|
|
|
&& screenShare.height === height
|
|
|
|
&& screenShare.browserWidth === browserWidth
|
|
|
|
&& screenShare.browserHeight === browserHeight) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
screenShare: {
|
|
|
|
...screenShare,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
browserWidth,
|
|
|
|
browserHeight,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-06-15 21:47:37 +08:00
|
|
|
case ACTIONS.SET_SCREEN_SHARE_OUTPUT: {
|
|
|
|
const {
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-07-07 03:27:28 +08:00
|
|
|
zIndex,
|
2021-06-15 21:47:37 +08:00
|
|
|
} = action.value;
|
|
|
|
const { screenShare } = state.output;
|
|
|
|
if (screenShare.width === width
|
|
|
|
&& screenShare.height === height
|
|
|
|
&& screenShare.top === top
|
2021-07-07 03:27:28 +08:00
|
|
|
&& screenShare.left === left
|
2021-07-27 04:28:05 +08:00
|
|
|
&& screenShare.right === right
|
2021-07-07 03:27:28 +08:00
|
|
|
&& screenShare.zIndex === zIndex) {
|
2021-06-15 21:47:37 +08:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
screenShare: {
|
|
|
|
...screenShare,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-07-07 03:27:28 +08:00
|
|
|
zIndex,
|
2021-06-15 21:47:37 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
|
2021-05-19 22:51:31 +08:00
|
|
|
// EXTERNAL VIDEO
|
2021-05-18 04:25:07 +08:00
|
|
|
case ACTIONS.SET_HAS_EXTERNAL_VIDEO: {
|
|
|
|
const { externalVideo } = state.input;
|
|
|
|
if (externalVideo.hasExternalVideo === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
externalVideo: {
|
|
|
|
...externalVideo,
|
|
|
|
hasExternalVideo: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
case ACTIONS.SET_EXTERNAL_VIDEO_SIZE: {
|
|
|
|
const {
|
|
|
|
width, height, browserWidth, browserHeight,
|
|
|
|
} = action.value;
|
|
|
|
const { externalVideo } = state.input;
|
|
|
|
if (externalVideo.width === width
|
|
|
|
&& externalVideo.height === height
|
|
|
|
&& externalVideo.browserWidth === browserWidth
|
|
|
|
&& externalVideo.browserHeight === browserHeight) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
externalVideo: {
|
|
|
|
...externalVideo,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
browserWidth,
|
|
|
|
browserHeight,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2021-06-16 20:53:27 +08:00
|
|
|
case ACTIONS.SET_EXTERNAL_VIDEO_OUTPUT: {
|
|
|
|
const {
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-06-16 20:53:27 +08:00
|
|
|
} = action.value;
|
|
|
|
const { externalVideo } = state.output;
|
|
|
|
if (externalVideo.width === width
|
|
|
|
&& externalVideo.height === height
|
|
|
|
&& externalVideo.top === top
|
2021-07-27 04:28:05 +08:00
|
|
|
&& externalVideo.left === left
|
|
|
|
&& externalVideo.right === right) {
|
2021-06-16 20:53:27 +08:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
externalVideo: {
|
|
|
|
...externalVideo,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
top,
|
|
|
|
left,
|
2021-07-27 04:28:05 +08:00
|
|
|
right,
|
2021-06-16 20:53:27 +08:00
|
|
|
},
|
|
|
|
},
|
2021-02-24 01:04:00 +08:00
|
|
|
};
|
|
|
|
}
|
2022-10-28 04:15:11 +08:00
|
|
|
|
|
|
|
// NOTES
|
2022-10-24 21:11:28 +08:00
|
|
|
case ACTIONS.SET_SHARED_NOTES_OUTPUT: {
|
|
|
|
const {
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
top,
|
|
|
|
left,
|
|
|
|
right,
|
|
|
|
} = action.value;
|
|
|
|
const { sharedNotes } = state.output;
|
|
|
|
if (sharedNotes.width === width
|
|
|
|
&& sharedNotes.height === height
|
|
|
|
&& sharedNotes.top === top
|
|
|
|
&& sharedNotes.left === left
|
|
|
|
&& sharedNotes.right === right) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
output: {
|
|
|
|
...state.output,
|
|
|
|
sharedNotes: {
|
|
|
|
...sharedNotes,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
top,
|
|
|
|
left,
|
|
|
|
right,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2022-10-28 04:15:11 +08:00
|
|
|
case ACTIONS.SET_NOTES_IS_PINNED: {
|
|
|
|
const { sharedNotes } = state.input;
|
|
|
|
if (sharedNotes.isPinned === action.value) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
input: {
|
|
|
|
...state.input,
|
|
|
|
sharedNotes: {
|
|
|
|
...sharedNotes,
|
|
|
|
isPinned: action.value,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2020-03-05 02:34:10 +08:00
|
|
|
default: {
|
|
|
|
throw new Error('Unexpected action');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-09-11 04:48:52 +08:00
|
|
|
const LayoutContextProvider = (props) => {
|
2021-08-05 19:03:24 +08:00
|
|
|
const [layoutContextState, layoutContextDispatch] = useReducer(reducer, initState);
|
2020-03-05 02:34:10 +08:00
|
|
|
const { children } = props;
|
|
|
|
return (
|
2021-09-09 21:51:18 +08:00
|
|
|
<LayoutContextSelector.Provider value={
|
|
|
|
[
|
|
|
|
layoutContextState,
|
|
|
|
layoutContextDispatch,
|
|
|
|
]
|
|
|
|
}
|
2020-03-05 02:34:10 +08:00
|
|
|
>
|
2021-09-10 21:16:44 +08:00
|
|
|
{children}
|
2021-09-09 21:51:18 +08:00
|
|
|
</LayoutContextSelector.Provider>
|
2020-03-05 02:34:10 +08:00
|
|
|
);
|
|
|
|
};
|
2021-09-11 04:48:52 +08:00
|
|
|
LayoutContextProvider.propTypes = providerPropTypes;
|
2020-03-05 02:34:10 +08:00
|
|
|
|
2021-09-11 04:48:52 +08:00
|
|
|
const layoutSelect = (selector) => {
|
2021-09-09 21:51:18 +08:00
|
|
|
return useContextSelector(LayoutContextSelector, layout => selector(layout[0]));
|
|
|
|
};
|
2021-09-11 04:48:52 +08:00
|
|
|
const layoutSelectInput = (selector) => {
|
2021-09-09 21:51:18 +08:00
|
|
|
return useContextSelector(LayoutContextSelector, layout => selector(layout[0].input));
|
|
|
|
};
|
2021-09-11 04:48:52 +08:00
|
|
|
const layoutSelectOutput = (selector) => {
|
2021-09-09 21:51:18 +08:00
|
|
|
return useContextSelector(LayoutContextSelector, layout => selector(layout[0].output));
|
|
|
|
};
|
|
|
|
const layoutDispatch = () => {
|
|
|
|
return useContextSelector(LayoutContextSelector, layout => layout[1]);
|
|
|
|
};
|
|
|
|
|
2021-09-11 04:48:52 +08:00
|
|
|
export {
|
|
|
|
LayoutContextProvider,
|
|
|
|
layoutSelect,
|
|
|
|
layoutSelectInput,
|
|
|
|
layoutSelectOutput,
|
|
|
|
layoutDispatch,
|
|
|
|
}
|