From 4c8da09df664fc7159f2e966ea28a7856660a36f Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 11 Mar 2025 16:14:29 +0200 Subject: [PATCH] Fixed: Movie Details crashing on invalid collection --- frontend/src/Movie/MovieCollectionLabel.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/Movie/MovieCollectionLabel.tsx b/frontend/src/Movie/MovieCollectionLabel.tsx index 9d0c4f022..afafd0d5c 100644 --- a/frontend/src/Movie/MovieCollectionLabel.tsx +++ b/frontend/src/Movie/MovieCollectionLabel.tsx @@ -4,6 +4,7 @@ import MonitorToggleButton from 'Components/MonitorToggleButton'; import { toggleCollectionMonitored } from 'Store/Actions/movieCollectionActions'; import { createCollectionSelectorForHook } from 'Store/Selectors/createCollectionSelector'; import MovieCollection from 'typings/MovieCollection'; +import translate from 'Utilities/String/translate'; import styles from './MovieCollectionLabel.css'; interface MovieCollectionLabelProps { @@ -16,7 +17,8 @@ function MovieCollectionLabel({ tmdbId }: MovieCollectionLabelProps) { monitored, title, isSaving = false, - } = useSelector(createCollectionSelectorForHook(tmdbId)) as MovieCollection; + } = useSelector(createCollectionSelectorForHook(tmdbId)) || + ({} as MovieCollection); const dispatch = useDispatch(); @@ -29,6 +31,10 @@ function MovieCollectionLabel({ tmdbId }: MovieCollectionLabelProps) { [id, dispatch] ); + if (!id) { + return translate('Unknown'); + } + return (