Files
gods-eye-view/src/ui/stores/radio.js
T
Sameh Khamis 61d11ce369 feat(radio): answer the RTL-SDR card through the radio store
SdrCard calls LocalSdrControls through radio store actions instead of
DOM listeners, and renders its gain options from the receiver's own
R820T gain steps with page-language labels. The display and radio
stores share one owner list (createOwners): the newest connected owner
with an action answers it.
2026-11-01 10:52:50 -08:00

63 lines
1.8 KiB
JavaScript

import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
import { createOwners } from './owners.js';
/**
* The Radio panel as its view renders it. RadioControls presents the
* directory row, station card, transport, volume and playback line and the
* Cockpit's compact radio controls (`renderRadioState()`), which Cockpit
* utility popover is open, and the directory tuner, and publishes them here;
* it keeps its listeners. LocalSdrControls publishes the local RTL-SDR card
* beside it, and the card's controls reach it through act().
*/
export const useRadioStore = defineStore('gev-radio', () => {
/** The presented panel; null until the controls first render. */
const view = shallowRef(null);
/** @param {object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = markRaw(next);
}
/** The local RTL-SDR card; null until its controls first render. */
const sdr = shallowRef(null);
/** @param {object} next A fresh presentation of the RTL-SDR card. */
function publishSdr(next) {
sdr.value = markRaw(next);
}
/** The open Cockpit utility popover; null until one first opens or closes. */
const utility = shallowRef(null);
/** @param {{display: boolean, radio: boolean}} next */
function publishUtility(next) {
utility.value = markRaw(next);
}
/** The directory tuner; null until the controls first present it. */
const tuner = shallowRef(null);
/** @param {object} next A fresh presentation of the tuner. */
function publishTuner(next) {
tuner.value = markRaw(next);
}
// LocalSdrControls answers the RTL-SDR card's controls.
const { connect, detach, act } = createOwners();
return {
view,
publish,
sdr,
publishSdr,
utility,
publishUtility,
tuner,
publishTuner,
connect,
detach,
act,
};
});