diff --git a/src/app/components/radio/radio.tsx b/src/app/components/radio/radio.tsx index a5c239c..32bc0fd 100644 --- a/src/app/components/radio/radio.tsx +++ b/src/app/components/radio/radio.tsx @@ -30,6 +30,13 @@ const Radio: React.FC = ({ radio }) => { const isATC = useSessionStore((state) => state.isAtc); + const clickRadioHeader = () => { + selectRadio(radio.frequency); + if (radio.transceiverCount === 0 && radio.callsign !== "MANUAL") { + void window.api.RefreshStation(radio.callsign); + } + } + const clickRx = () => { const newState = !radio.rx; @@ -40,7 +47,7 @@ const Radio: React.FC = ({ radio }) => { newState ? radio.tx : false, newState ? radio.xc : false, radio.onSpeaker, - newState ? radio.crossCoupleAcross : false, + newState ? radio.crossCoupleAcross : false ) .then((ret) => { if (!ret) { @@ -53,7 +60,7 @@ const Radio: React.FC = ({ radio }) => { setXc(radio.frequency, newState ? radio.xc : false); setCrossCoupleAcross( radio.frequency, - newState ? radio.crossCoupleAcross : false, + newState ? radio.crossCoupleAcross : false ); }) .catch((err: unknown) => { @@ -67,11 +74,11 @@ const Radio: React.FC = ({ radio }) => { window.api .setFrequencyState( radio.frequency, - radio.rx, + newState ? true : radio.rx, // If tx is true, rx must be true newState, - !newState ? false : radio.xc, + !newState ? false : radio.xc, // If tx is false, xc must be false radio.onSpeaker, - !newState ? false : radio.crossCoupleAcross, + !newState ? false : radio.crossCoupleAcross // If tx is false, crossCoupleAcross must be false ) .then((ret) => { if (!ret) { @@ -79,6 +86,12 @@ const Radio: React.FC = ({ radio }) => { return; } setTx(radio.frequency, newState); + setRx(radio.frequency, newState ? true : radio.rx); + setXc(radio.frequency, !newState ? false : radio.xc); + setCrossCoupleAcross( + radio.frequency, + !newState ? false : radio.crossCoupleAcross + ); }) .catch((err: unknown) => { console.error(err); @@ -90,17 +103,19 @@ const Radio: React.FC = ({ radio }) => { window.api .setFrequencyState( radio.frequency, - radio.rx, - radio.tx, + newState ? true : radio.rx, // If xc is true, rx must be true + newState ? true : radio.tx, // If xc is true, tx must be true newState, radio.onSpeaker, - false, + false // If xc is true, crossCoupleAcross must be false ) .then((ret) => { if (!ret) { postError("Invalid action on invalid radio: XC."); return; } + setRx(radio.frequency, newState ? true : radio.rx); + setTx(radio.frequency, newState ? true : radio.tx); setXc(radio.frequency, newState); setCrossCoupleAcross(radio.frequency, false); }) @@ -114,17 +129,19 @@ const Radio: React.FC = ({ radio }) => { window.api .setFrequencyState( radio.frequency, - radio.rx, - radio.tx, - false, + newState ? true : radio.rx, // If crossCoupleAcross is true, rx must be true + newState ? true : radio.tx, // If crossCoupleAcross is true, tx must be true + false, // If crossCoupleAcross is true, xc must be false radio.onSpeaker, - newState, + newState ) .then((ret) => { if (!ret) { postError("Invalid action on invalid radio: XC across."); return; } + setRx(radio.frequency, newState ? true : radio.rx); + setTx(radio.frequency, newState ? true : radio.tx); setXc(radio.frequency, false); setCrossCoupleAcross(radio.frequency, newState); }) @@ -142,7 +159,7 @@ const Radio: React.FC = ({ radio }) => { radio.tx, radio.xc, newState, - radio.crossCoupleAcross, + radio.crossCoupleAcross ) .then((ret) => { if (!ret) { @@ -164,9 +181,7 @@ const Radio: React.FC = ({ radio }) => { @@ -190,7 +205,7 @@ const Radio: React.FC = ({ radio }) => { className={clsx( "btn", !radio.onSpeaker && "btn-primary", - radio.onSpeaker && "btn-success", + radio.onSpeaker && "btn-success" )} style={{ width: "45%", @@ -216,7 +231,7 @@ const Radio: React.FC = ({ radio }) => { "btn", !radio.rx && "btn-primary", radio.rx && radio.currentlyRx && "btn-warning", - radio.rx && !radio.currentlyRx && "btn-success", + radio.rx && !radio.currentlyRx && "btn-success" )} style={{ width: "100%", height: "100%" }} onClick={clickRx} @@ -228,11 +243,11 @@ const Radio: React.FC = ({ radio }) => { "btn", !radio.tx && "btn-primary", radio.tx && radio.currentlyTx && "btn-warning", - radio.tx && !radio.currentlyTx && "btn-success", + radio.tx && !radio.currentlyTx && "btn-success" )} style={{ width: "100%", height: "100%", marginTop: "8%" }} onClick={clickTx} - disabled={!isATC || !radio.rx} + disabled={!isATC} > TX diff --git a/src/app/components/settings-modal/settings-modal.tsx b/src/app/components/settings-modal/settings-modal.tsx index a9338d2..ecd25c1 100644 --- a/src/app/components/settings-modal/settings-modal.tsx +++ b/src/app/components/settings-modal/settings-modal.tsx @@ -2,12 +2,12 @@ import React, { useEffect, useState } from "react"; import AudioApis from "./audio-apis"; import AudioInput from "./audio-input"; import AudioOutputs from "./audio-outputs"; +import useUtilStore from "../../store/utilStore"; +import clsx from "clsx"; +import useSessionStore from "../../store/sessionStore"; import { useDebouncedCallback } from "use-debounce"; import { Configuration } from "../../../config.d"; -import useSessionStore from "../../store/sessionStore"; import { getKeyFromNumber } from "../../../helper"; -import useUtilStore from "../../store/utilStore"; -import clsx from "clsx"; import { AudioApi, AudioDevice } from "trackaudio-afv"; export interface SettingsModalProps { @@ -24,10 +24,10 @@ const SettingsModal: React.FC = ({ closeModal }) => { const [changesSaved, setChangesSaved] = useState(SaveStatus.NoChanges); const [audioApis, setAudioApis] = useState(Array); const [audioOutputDevices, setAudioOutputDevices] = useState( - Array, + Array ); const [audioInputDevices, setAudioInputDevices] = useState( - Array, + Array ); const [hardwareType, setHardwareType] = useState(0); const [config, setConfig] = useState({} as Configuration); @@ -42,7 +42,11 @@ const SettingsModal: React.FC = ({ closeModal }) => { const [cid, setCid] = useState(""); const [password, setPassword] = useState(""); - const [vu, vuPeak, updateVu] = useUtilStore((state) => [state.vu, state.peakVu, state.updateVu]); + const [vu, vuPeak, updateVu] = useUtilStore((state) => [ + state.vu, + state.peakVu, + state.updateVu, + ]); const [isMicTesting, setIsMicTesting] = useState(false); useEffect(() => { @@ -180,7 +184,7 @@ const SettingsModal: React.FC = ({ closeModal }) => { }; const handleHardwareTypeChange = ( - e: React.ChangeEvent, + e: React.ChangeEvent ) => { setChangesSaved(SaveStatus.Saving); const hardwareType = parseInt(e.target.value); @@ -299,7 +303,7 @@ const SettingsModal: React.FC = ({ closeModal }) => { className={clsx( "btn mt-3 w-100", !isMicTesting && "btn-info", - isMicTesting && "btn-warning", + isMicTesting && "btn-warning" )} onClick={handleMicTest} disabled={ diff --git a/src/app/components/sidebar/radio-status.tsx b/src/app/components/sidebar/radio-status.tsx index a4587fe..8a2160d 100644 --- a/src/app/components/sidebar/radio-status.tsx +++ b/src/app/components/sidebar/radio-status.tsx @@ -19,6 +19,9 @@ const RadioStatus: React.FC = () => { if (!selectedRadio) { return; } + if (selectedRadio.callsign === "MANUAL") { + return; + } void window.api.RefreshStation(selectedRadio.callsign); }; diff --git a/src/index.ts b/src/index.ts index ba284ad..daf813c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -95,7 +95,7 @@ const createWindow = (): void => { mainWindow = new BrowserWindow({ height: 660, width: 800, - minWidth: 200, + minWidth: 210, minHeight: 120, webPreferences: { preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,