From fadc3bc8c77bad59e138f769e6e8955e7c42b30a Mon Sep 17 00:00:00 2001 From: Attila Farago Date: Sat, 30 Aug 2025 22:05:08 +0000 Subject: [PATCH] firmware/installPybricksDialog/hooks: dispatch error if no url Dispatch an error in case there is no firmware URL. Normally this should never happen, but currently it does because we don't have EV3 firmware yet. The error is more useful than just spinning forever. --- src/firmware/installPybricksDialog/hooks.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/firmware/installPybricksDialog/hooks.ts b/src/firmware/installPybricksDialog/hooks.ts index e3c5999f..684e7b38 100644 --- a/src/firmware/installPybricksDialog/hooks.ts +++ b/src/firmware/installPybricksDialog/hooks.ts @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2022-2023 The Pybricks Authors +// Copyright (c) 2022-2025 The Pybricks Authors // based on https://usehooks-ts.com/react-hook/use-fetch import { FirmwareMetadata, FirmwareReader } from '@pybricks/firmware'; @@ -78,8 +78,10 @@ export function useFirmware(hubType: Hub): State { const [state, dispatch] = useReducer(fetchReducer, initialState); useEffect(() => { - // Do nothing if the url is not given + // Raise error if the url is not given, to show that something is wrong + // instead of a misleading intermediate state. if (!url) { + dispatch({ type: 'error', payload: new Error('No URL for this hub type') }); return; }