Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix state problems with main volume dial #389

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"svg.preview.background": "editor",
"cSpell.words": [
"ATIS",
"Autopurge",
"Callsign",
"callsigns",
Expand All @@ -31,6 +32,7 @@
"stationvolume",
"streamdeck",
"trackaudio",
"Typeguard"
"Typeguard",
"vatsim"
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 24 additions & 5 deletions src/controllers/mainVolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,47 @@ 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 {
const color = trackAudioManager.isVoiceConnected ? "white" : "grey";
if (!trackAudioManager.isVoiceConnected) {
this.action
.setFeedback({
title: {
color: "grey",
},
indicator: {
value: 0,
bar_fill_c: "grey",
},
value: {
value: "",
color: "grey",
},
})
.catch((error: unknown) => {
handleAsyncException("Unable to set dial feedback: ", error);
});
return;
}

this.action
.setFeedback({
title: {
color: color,
color: "white",
},
indicator: {
value: this.volume,
color,
bar_fill_c: "white",
},
value: {
value: `${this.volume.toString()}%`,
color,
color: "white",
},
})
.catch((error: unknown) => {
Expand Down
6 changes: 1 addition & 5 deletions src/controllers/stationVolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,7 @@ export class StationVolumeController extends BaseController {
}

private refreshTitle(): void {
if (
!trackAudioManager.isConnected ||
!trackAudioManager.isVoiceConnected ||
!this.isAvailable
) {
if (!trackAudioManager.isVoiceConnected || !this.isAvailable) {
this.action
.setFeedback({
title: {
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/voiceConnectedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const handleVoiceConnectedState = async (data: VoiceConnectedState) => {

if (data.value.connected) {
trackAudioManager.refreshStationStates();
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