Skip to content

Commit f5e5a02

Browse files
committed
Merge branch 'metadata-rework-reduce-rerenders' of Arnei/opencast-editor into r/18.x
Pull request #1608 Reduce rerenders in the metadata tab
2 parents be90e74 + 0599f27 commit f5e5a02

File tree

9 files changed

+495
-645
lines changed

9 files changed

+495
-645
lines changed

src/cssStyles.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ type MyOptionType = {
171171
value: string;
172172
};
173173

174-
type IsMulti = false;
175-
176-
export function selectFieldStyle(theme: Theme): StylesConfig<MyOptionType, IsMulti> {
174+
export function selectFieldStyle<IsMulti extends boolean, >(theme: Theme): StylesConfig<MyOptionType, IsMulti> {
177175
return {
178176
control: (provided, state) => ({
179177
...provided,

src/main/Cutting.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { LuHourglass } from "react-icons/lu";
3131
import { css } from "@emotion/react";
3232
import VideoPlayers from "./VideoPlayers";
3333
import VideoControls from "./VideoControls";
34+
import { fetchMetadata, selectGetStatus as selectMetadataGetStatus } from "../redux/metadataSlice";
3435

3536
const Cutting: React.FC = () => {
3637

@@ -47,6 +48,7 @@ const Cutting: React.FC = () => {
4748
const theme = useTheme();
4849
const errorReason = useAppSelector((state: { videoState: { errorReason: httpRequestState["errorReason"]; }; }) =>
4950
state.videoState.errorReason);
51+
const metadataGetStatus = useAppSelector(selectMetadataGetStatus);
5052

5153
// Try to fetch URL from external API
5254
useEffect(() => {
@@ -86,6 +88,13 @@ const Cutting: React.FC = () => {
8688
}
8789
}, [videoURLStatus, dispatch, error, t, errorReason, duration, videos]);
8890

91+
// Already try fetching Metadata to reduce wait time
92+
useEffect(() => {
93+
if (metadataGetStatus === "idle") {
94+
dispatch(fetchMetadata());
95+
}
96+
}, [metadataGetStatus, dispatch]);
97+
8998
// Style
9099
const cuttingStyle = css({
91100
display: "flex",

0 commit comments

Comments
 (0)