diff --git a/frontend/src/basic/RobotPage/RobotProfile.tsx b/frontend/src/basic/RobotPage/RobotProfile.tsx index 4a21bfbb8..55bd5fe7d 100644 --- a/frontend/src/basic/RobotPage/RobotProfile.tsx +++ b/frontend/src/basic/RobotPage/RobotProfile.tsx @@ -67,9 +67,11 @@ const RobotProfile = ({ }; const handleChangeSlot = (e: SelectChangeEvent): void => { - garage.currentSlot = e.target.value; - setInputToken(garage.getSlot()?.token ?? ''); - setLoading(true); + if (e?.target?.value) { + garage.setCurrentSlot(e.target.value as string); + setInputToken(garage.getSlot()?.token ?? ''); + setLoading(true); + } }; const slot = garage.getSlot(); diff --git a/frontend/src/basic/RobotPage/index.tsx b/frontend/src/basic/RobotPage/index.tsx index 5ff2599fd..0902c2aae 100644 --- a/frontend/src/basic/RobotPage/index.tsx +++ b/frontend/src/basic/RobotPage/index.tsx @@ -71,7 +71,7 @@ const RobotPage = (): JSX.Element => { encPrivKey: key.encryptedPrivateKeyArmored, }); void federation.fetchRobot(garage, token); - garage.currentSlot = token; + garage.setCurrentSlot(token); }) .catch((error) => { console.error('Error:', error); diff --git a/frontend/src/models/Garage.model.ts b/frontend/src/models/Garage.model.ts index 47204b918..fd820fc2a 100644 --- a/frontend/src/models/Garage.model.ts +++ b/frontend/src/models/Garage.model.ts @@ -106,6 +106,11 @@ class Garage { return slot; }; + setCurrentSlot: (currentSlot: string) => void = (currentSlot) => { + this.currentSlot = currentSlot; + this.triggerHook('onRobotUpdate'); + }; + // Robots createRobot: (token: string, shortAliases: string[], attributes: Record) => void = ( token,