From 9ab03ee6393272204ef02610665eb7e9ba4ab88d Mon Sep 17 00:00:00 2001 From: Pierre Ferran Date: Thu, 9 May 2024 19:17:44 -0400 Subject: [PATCH] Await before deleting frequency --- src/app/components/bootstrap.tsx | 2 +- src/app/components/sidebar/radio-status.tsx | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/app/components/bootstrap.tsx b/src/app/components/bootstrap.tsx index 09453ab..f78ab65 100644 --- a/src/app/components/bootstrap.tsx +++ b/src/app/components/bootstrap.tsx @@ -75,7 +75,7 @@ const Bootsrap: React.FC = () => { if (useRadioState.getState().isInactive(parseInt(frequency))) { return; } - + useRadioState.getState().setCurrentlyRx(parseInt(frequency), false); }); diff --git a/src/app/components/sidebar/radio-status.tsx b/src/app/components/sidebar/radio-status.tsx index 8a2160d..0fd86aa 100644 --- a/src/app/components/sidebar/radio-status.tsx +++ b/src/app/components/sidebar/radio-status.tsx @@ -11,8 +11,21 @@ const RadioStatus: React.FC = () => { if (!selectedRadio) { return; } - void window.api.removeFrequency(selectedRadio.frequency); - removeRadio(selectedRadio.frequency); + void window.api + .setFrequencyState( + selectedRadio.frequency, + false, + false, + false, + false, + false, + ) + .then(() => { + setTimeout(() => { + void window.api.removeFrequency(selectedRadio.frequency); + removeRadio(selectedRadio.frequency); + }, 500); + }); }; const handleForceRefresh = () => {