diff --git a/client/package.json b/client/package.json
index 886e0b989..661b9195b 100644
--- a/client/package.json
+++ b/client/package.json
@@ -16,6 +16,7 @@
"react": "^17.0.1",
"react-beautiful-dnd": "^13.1.0",
"react-dom": "^17.0.1",
+ "react-fast-compare": "^3.2.0",
"react-icons": "^4.2.0",
"react-qr-code": "^1.1.1",
"react-query": "^3.13.5",
diff --git a/client/src/features/viewers/production/lower/LowerClean.jsx b/client/src/features/viewers/production/lower/LowerClean.jsx
index 780a3e1ef..fb9fc8c40 100644
--- a/client/src/features/viewers/production/lower/LowerClean.jsx
+++ b/client/src/features/viewers/production/lower/LowerClean.jsx
@@ -33,6 +33,7 @@ export default function LowerClean(props) {
// calculate transition times
useEffect(() => {});
+
// Format messages
const showLowerMessage = lower.text !== '' && lower.visible;
diff --git a/client/src/features/viewers/production/lower/LowerLines.jsx b/client/src/features/viewers/production/lower/LowerLines.jsx
index 7c2c28d66..f96963c1d 100644
--- a/client/src/features/viewers/production/lower/LowerLines.jsx
+++ b/client/src/features/viewers/production/lower/LowerLines.jsx
@@ -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;
diff --git a/client/src/features/viewers/production/lower/LowerWrapper.jsx b/client/src/features/viewers/production/lower/LowerWrapper.jsx
index 0ee5cae91..bc1f9cc90 100644
--- a/client/src/features/viewers/production/lower/LowerWrapper.jsx
+++ b/client/src/features/viewers/production/lower/LowerWrapper.jsx
@@ -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 ;
+ return (
+
+ );
case 1:
- return ;
+ return (
+
+ );
default:
- return ;
+ return (
+
+ );
}
-}
+};
+
+export default memo(Lower, areEqual);
diff --git a/client/yarn.lock b/client/yarn.lock
index 1062924a6..84ee4f1c6 100644
--- a/client/yarn.lock
+++ b/client/yarn.lock
@@ -10078,7 +10078,7 @@ react-error-overlay@^6.0.9:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==
-react-fast-compare@3.2.0:
+react-fast-compare@3.2.0, react-fast-compare@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"
integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==