mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 18:03:47 +00:00
Merge branch 'master' into feat/electron
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
|
||||
import { lazy, useEffect } from 'react';
|
||||
import { Heading } from '@chakra-ui/layout';
|
||||
import { Box } from '@chakra-ui/layout';
|
||||
import PlaybackControl from '../control/PlaybackControl';
|
||||
import MessageControl from '../control/MessageControl';
|
||||
import NumberedText from 'common/components/text/NumberedText';
|
||||
import styles from './Editor.module.css';
|
||||
import EventListWrapper from './list/EventListWrapper';
|
||||
import { useDisclosure } from '@chakra-ui/hooks';
|
||||
import SettingsModal from '../modals/SettingsModal';
|
||||
import { useEffect } from 'react';
|
||||
import MenuBar from 'features/menu/MenuBar';
|
||||
|
||||
const EventListWrapper = lazy(() =>
|
||||
import('features/editors/list/EventListWrapper')
|
||||
);
|
||||
const PlaybackControl = lazy(() => import('features/control/PlaybackControl'));
|
||||
const MessageControl = lazy(() => import('features/control/MessageControl'));
|
||||
|
||||
export default function Editor() {
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
|
||||
|
||||
@@ -71,11 +71,7 @@ export default function PresenterView(props) {
|
||||
isPlaying ? style.progressContainer : style.progressContainerPaused
|
||||
}
|
||||
>
|
||||
<MyProgressBar
|
||||
now={normalisedTime}
|
||||
complete={time.durationSeconds}
|
||||
showElapsed
|
||||
/>
|
||||
<MyProgressBar now={normalisedTime} complete={time.durationSeconds} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ export default function LowerClean(props) {
|
||||
|
||||
// calculate transition times
|
||||
useEffect(() => {});
|
||||
|
||||
// Format messages
|
||||
const showLowerMessage = lower.text !== '' && lower.visible;
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ export default function LowerLines(props) {
|
||||
return () => clearTimeout(timeout);
|
||||
}, [options.fadeOut, options.transitionIn, defaults.transitionIn]);
|
||||
|
||||
useEffect(() => {
|
||||
setShowLower(title.showNow);
|
||||
}, [title.showNow]);
|
||||
|
||||
// Format messages
|
||||
const showLowerMessage = lower.text !== '' && lower.visible;
|
||||
|
||||
|
||||
@@ -1,8 +1,27 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { memo, useEffect, useState } from 'react';
|
||||
import LowerClean from './LowerClean';
|
||||
import LowerLines from './LowerLines';
|
||||
const isEqual = require('react-fast-compare');
|
||||
|
||||
export default function Lower(props) {
|
||||
const areEqual = (prevProps, nextProps) => {
|
||||
return (
|
||||
isEqual(prevProps.title, nextProps.title) &&
|
||||
isEqual(prevProps.lower && nextProps.lower)
|
||||
);
|
||||
};
|
||||
|
||||
const Lower = (props) => {
|
||||
const { title } = props;
|
||||
const [titles, setTitles] = useState({
|
||||
titleNow: '',
|
||||
titleNext: '',
|
||||
subtitleNow: '',
|
||||
subtitleNext: '',
|
||||
presenterNow: '',
|
||||
presenterNext: '',
|
||||
showNow: false,
|
||||
showNext: false,
|
||||
});
|
||||
const [preset, setPreset] = useState(1);
|
||||
const [lowerOptions, setLowerOptions] = useState({});
|
||||
|
||||
@@ -11,6 +30,32 @@ export default function Lower(props) {
|
||||
document.title = 'ontime - Lower Thirds';
|
||||
}, []);
|
||||
|
||||
// reload if data changes
|
||||
useEffect(() => {
|
||||
// clear titles if necessary
|
||||
// will trigger an animation out in the component
|
||||
let timeout = null;
|
||||
if (
|
||||
title?.titleNow !== titles?.titleNow ||
|
||||
title?.subtitleNow !== titles?.subtitleNow ||
|
||||
title?.presenterNow !== titles?.presenterNow
|
||||
) {
|
||||
setTitles((t) => ({ ...t, showNow: false }));
|
||||
|
||||
const transitionTime = 2000;
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
setTitles(title);
|
||||
}, transitionTime);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (timeout != null) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
};
|
||||
}, [title.titleNow, title.subtitleNow, title.presenterNow]);
|
||||
|
||||
// TODO: sanitize data
|
||||
// getting config from URL: preset, size, transition, bg, text, key
|
||||
// eg. http://localhost:3000/lower?bg=ff2&text=f00&size=0.6&transition=5
|
||||
@@ -77,10 +122,18 @@ export default function Lower(props) {
|
||||
|
||||
switch (preset) {
|
||||
case 0:
|
||||
return <LowerClean {...props} options={lowerOptions} />;
|
||||
return (
|
||||
<LowerClean lower={props.lower} title={titles} options={lowerOptions} />
|
||||
);
|
||||
case 1:
|
||||
return <LowerLines {...props} options={lowerOptions} />;
|
||||
return (
|
||||
<LowerLines lower={props.lower} title={titles} options={lowerOptions} />
|
||||
);
|
||||
default:
|
||||
return <LowerLines {...props} options={lowerOptions} />;
|
||||
return (
|
||||
<LowerLines lower={props.lower} title={titles} options={lowerOptions} />
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default memo(Lower, areEqual);
|
||||
|
||||
Reference in New Issue
Block a user