From d8c68496a9686af83c8cc31f844f2bc63a0ff5ca Mon Sep 17 00:00:00 2001 From: Thomas Churchman Date: Thu, 15 Feb 2024 11:13:36 +0100 Subject: [PATCH] fix: correctly find peripherals in Media component --- src/scenes/kit/kit-data/Media.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/scenes/kit/kit-data/Media.tsx b/src/scenes/kit/kit-data/Media.tsx index 18ab96a..1135af5 100644 --- a/src/scenes/kit/kit-data/Media.tsx +++ b/src/scenes/kit/kit-data/Media.tsx @@ -115,8 +115,10 @@ export default function Media({ kit, configuration }: Props) { { - configuration.peripherals[displayMedia.peripheralId]! - .name + configuration.peripherals.find( + (peripheral) => + peripheral.id === displayMedia.peripheralId, + )?.name } {displayMedia.name} @@ -142,7 +144,9 @@ export default function Media({ kit, configuration }: Props) { {mediaList.map((media) => { - const peripheral = configuration.peripherals[media.peripheralId]!; + const peripheral = configuration.peripherals.find( + (peripheral) => peripheral.id === media.peripheralId, + ); const displayable = media.type === "image/png" || media.type === "image/jpeg" || @@ -152,6 +156,9 @@ export default function Media({ kit, configuration }: Props) { displayMedia !== null && displayMedia.id === media.id && displayUrl === null; + if (peripheral === undefined) { + return; + } return (