Skip to content

Commit

Permalink
More fixing of state problems
Browse files Browse the repository at this point in the history
  • Loading branch information
neilenns committed Jan 13, 2025
1 parent 54fc6a2 commit 3bad519
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/controllers/mainVolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { handleAsyncException } from "@utils/handleAsyncException";
import { stringOrUndefined } from "@utils/utils";
import debounce from "debounce";
import { BaseController } from "./baseController";
import mainLogger from "@utils/logger";

const logger = mainLogger.child({ service: "mainVolumeController" });

const defaultConnectedTemplatePath = "images/actions/mainVolume/template.svg";
const defaultNotConnectedTemplatePath =
Expand Down Expand Up @@ -134,14 +137,19 @@ export class MainVolumeController extends BaseController {
state: trackAudioManager.isVoiceConnected ? "connected" : "notConnected",
};

const templatePath = trackAudioManager.isConnected
const templatePath = trackAudioManager.isVoiceConnected
? this.connectedTemplatePath
: this.notConnectedTemplatePath;

this.setFeedbackImage(templatePath, replacements);
}

private refreshTitle(): void {
logger.info(
`mainVolume refresh title, isVoiceConnected is ${
trackAudioManager.isConnected ? "true" : "false"
}`
);
if (!trackAudioManager.isVoiceConnected) {
this.action
.setFeedback({
Expand Down
1 change: 0 additions & 1 deletion src/events/trackAudio/connected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export const handleConnected = () => {
});

trackAudioManager.refreshVoiceConnectedState(); // This will force an update of station states as well if voice is connected.
trackAudioManager.refreshMainVolume(); // This will force an update of the main volume knobs
};
1 change: 1 addition & 0 deletions src/events/trackAudio/mainVolumeChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const handleMainVolumeChange = (data: MainVolumeChange) => {

try {
actionManager.getMainVolumeControllers().forEach((entry) => {
logger.info(`Setting mainVolume to ${data.value.volume.toString()}`);
entry.volume = data.value.volume;
});
} catch (error: unknown) {
Expand Down
2 changes: 1 addition & 1 deletion src/events/trackAudio/voiceConnectedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const handleVoiceConnectedState = async (data: VoiceConnectedState) => {

if (data.value.connected) {
trackAudioManager.refreshStationStates();
trackAudioManager.refreshMainVolume();
trackAudioManager.refreshMainVolume(); // This will force an update of the main volume knobs

// Only start polling VATSIM if there are ATIS letters.
if (actionManager.getAtisLetterControllers().length > 0) {
Expand Down

0 comments on commit 3bad519

Please sign in to comment.