From 32396cd4273385aeeb1069c3c2c4ced47fbbfcba Mon Sep 17 00:00:00 2001
From: cv <34649812+cpvalente@users.noreply.github.com>
Date: Sat, 29 May 2021 12:32:36 +0200
Subject: [PATCH] small fixes
- paginator shows correctly past - now - future
- uselayouteffect in pip
- scroll into view would crash if event was deleted
---
client/src/common/components/views/Paginator.jsx | 4 +++-
client/src/features/editors/list/EventList.jsx | 1 +
client/src/features/viewers/production/Pip.jsx | 4 ++--
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/client/src/common/components/views/Paginator.jsx b/client/src/common/components/views/Paginator.jsx
index 9fcb89762..28ed3e543 100644
--- a/client/src/common/components/views/Paginator.jsx
+++ b/client/src/common/components/views/Paginator.jsx
@@ -53,6 +53,8 @@ export default function Paginator(props) {
}
}, SCROLL_TIME);
+ let selectedState = 0;
+
return (
<>
@@ -66,7 +68,7 @@ export default function Paginator(props) {
{page.map((e) => {
- let selectedState = 0;
+ if (selectedState === 1) selectedState = 2;
if (e.id === selected) selectedState = 1;
else if (e.id > selected) selectedState = 2;
return (
diff --git a/client/src/features/editors/list/EventList.jsx b/client/src/features/editors/list/EventList.jsx
index befda8cec..df66b4a9d 100644
--- a/client/src/features/editors/list/EventList.jsx
+++ b/client/src/features/editors/list/EventList.jsx
@@ -77,6 +77,7 @@ export default function EventList(props) {
// when cursor moves, view should follow
useEffect(() => {
+ if (cursorRef.current == null) return;
cursorRef.current.scrollIntoView({
behavior: 'smooth',
block: 'nearest',
diff --git a/client/src/features/viewers/production/Pip.jsx b/client/src/features/viewers/production/Pip.jsx
index 15d6385a0..b793d6e2b 100644
--- a/client/src/features/viewers/production/Pip.jsx
+++ b/client/src/features/viewers/production/Pip.jsx
@@ -3,7 +3,7 @@ import style from './Pip.module.css';
import Paginator from 'common/components/views/Paginator';
import NavLogo from 'common/components/nav/NavLogo';
import { AnimatePresence, motion } from 'framer-motion';
-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import { formatDisplay } from 'common/dateConfig';
import { ReactComponent as Emptyimage } from 'assets/images/empty.svg';
@@ -14,7 +14,7 @@ export default function Pip(props) {
const [filteredEvents, setFilteredEvents] = useState(null);
// calculcate pip size
- useEffect(() => {
+ useLayoutEffect(() => {
const h = ref.current.clientHeight;
const w = ref.current.clientWidth;
setSize(`${w} x ${h}`);