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

Dim volume dials when no voice connection is available #378

Merged
merged 3 commits into from
Jan 12, 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
15 changes: 8 additions & 7 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"recommendations": [
"paulober.rollup-problem-matcher",
"davidanson.vscode-markdownlint",
"yzhang.markdown-all-in-one",
"jock.svg"
]
}
"recommendations": [
"paulober.rollup-problem-matcher",
"davidanson.vscode-markdownlint",
"yzhang.markdown-all-in-one",
"jock.svg",
"streetsidesoftware.code-spell-checker"
]
}
13 changes: 12 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,16 @@
"editor.formatOnSave": false
},
"svg.preview.background": "editor",
"cSpell.words": ["elgato", "streamdeck"]
"cSpell.words": [
"Autopurge",
"Callsign",
"callsigns",
"coms",
"elgato",
"stationstatus",
"stationvolume",
"streamdeck",
"trackaudio",
"Typeguard"
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions src/controllers/mainVolume.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { MainVolumeSettings } from "@actions/mainVolume";
import { DialAction } from "@elgato/streamdeck";
import { Controller } from "@interfaces/controller";
import trackAudioManager from "@managers/trackAudio";
import { MAIN_VOLUME_CONTROLLER_TYPE } from "@utils/controllerTypes";
import { handleAsyncException } from "@utils/handleAsyncException";
import { stringOrUndefined } from "@utils/utils";
import debounce from "debounce";
import { BaseController } from "./baseController";
import { MAIN_VOLUME_CONTROLLER_TYPE } from "@utils/controllerTypes";

const defaultConnectedTemplatePath = "images/actions/mainVolume/template.svg";
const defaultNotConnectedTemplatePath =
Expand Down Expand Up @@ -57,7 +58,7 @@ export class MainVolumeController extends BaseController {
}

/**
* Gets the notconnected SVG template path.
* Gets the not connected SVG template path.
*/
get notConnectedTemplatePath(): string {
return this._notConnectedTemplatePath ?? defaultNotConnectedTemplatePath;
Expand Down Expand Up @@ -151,24 +152,31 @@ export class MainVolumeController extends BaseController {
private refreshImage(): void {
const replacements = {
volume: this.volume,
state: this.isConnected ? "connected" : "notConnected",
state: trackAudioManager.isVoiceConnected ? "connected" : "notConnected",
};

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

this.setFeedbackImage(templatePath, replacements);
}

private refreshTitle(): void {
const color = trackAudioManager.isVoiceConnected ? "white" : "grey";

this.action
.setFeedback({
title: {
color: color,
},
indicator: {
value: this.volume,
color,
},
value: {
value: `${this.volume.toString()}%`,
color,
},
})
.catch((error: unknown) => {
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { KeyAction } from "@elgato/streamdeck";
import { Controller } from "@interfaces/controller";
import TitleBuilder from "@root/utils/titleBuilder";
import { stringOrUndefined } from "@root/utils/utils";
import { STATION_STATUS_CONTROLLER_TYPE } from "@utils/controllerTypes";
import mainLogger from "@utils/logger";
import debounce from "debounce";
import { LRUCache } from "lru-cache";
import { BaseController } from "./baseController";
import debounce from "debounce";
import mainLogger from "@utils/logger";
import { STATION_STATUS_CONTROLLER_TYPE } from "@utils/controllerTypes";

// Valid values for the ListenTo property. This must match
// the list of array property names that come from TrackAudio
Expand Down Expand Up @@ -211,7 +211,7 @@ export class StationStatusController extends BaseController {
}

/**
* Returns the frequency formated for display. A value of 121900000
* Returns the frequency formatted for display. A value of 121900000
* will be returned as "121.900". If the frequency is undefined or 0
* then an empty string is returned.
*/
Expand All @@ -224,7 +224,7 @@ export class StationStatusController extends BaseController {
}

/**
* Conveinence property to get the listenTo value of settings.
* Convenience property to get the listenTo value of settings.
*/
get listenTo() {
return this.settings.listenTo ?? "rx";
Expand Down Expand Up @@ -384,7 +384,7 @@ export class StationStatusController extends BaseController {
}

/**
* True if the station is actively receiveing.
* True if the station is actively receiving.
*/
get isReceiving() {
return this._isReceiving;
Expand Down
34 changes: 23 additions & 11 deletions src/controllers/stationVolume.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { StationVolumeSettings } from "@actions/stationVolume";
import { BaseController } from "./baseController";
import { DialAction } from "@elgato/streamdeck";
import { Controller } from "@interfaces/controller";
import { stringOrUndefined } from "@utils/utils";
import trackAudioManager from "@managers/trackAudio";
import { STATION_VOLUME_CONTROLLER_TYPE } from "@utils/controllerTypes";
import { handleAsyncException } from "@utils/handleAsyncException";
import { stringOrUndefined } from "@utils/utils";
import debounce from "debounce";
import { STATION_VOLUME_CONTROLLER_TYPE } from "@utils/controllerTypes";
import { BaseController } from "./baseController";

const defaultTemplatePath = "images/actions/stationVolume/template.svg";

Expand All @@ -21,7 +22,7 @@ export class StationVolumeController extends BaseController {
private _notMutedTemplatePath?: string;
private _outputVolume? = 100;
private _settings: StationVolumeSettings | null = null;
private _unavilableTemplatePath?: string;
private _unavailableTemplatePath?: string;

/**
* Creates a new StationVolumeController object.
Expand Down Expand Up @@ -75,14 +76,14 @@ export class StationVolumeController extends BaseController {
* Gets the unavailable SVG template path.
*/
get unavailableTemplatePath(): string {
return this._unavilableTemplatePath ?? defaultTemplatePath;
return this._unavailableTemplatePath ?? defaultTemplatePath;
}

/**
* Sets the unavailable SVG template path.
*/
set unavailableTemplatePath(newValue: string | undefined) {
this._unavilableTemplatePath = stringOrUndefined(newValue);
this._unavailableTemplatePath = stringOrUndefined(newValue);
}

/**
Expand Down Expand Up @@ -223,8 +224,16 @@ export class StationVolumeController extends BaseController {
volume: this.outputVolume,
};

// Set the unavilable state if the station is not available.
if (this.isAvailable !== undefined && !this.isAvailable) {
if (!trackAudioManager.isVoiceConnected) {
this.setFeedbackImage(this.notMutedTemplatePath, {
...replacements,
state: "notConnected",
});
return;
}

// Set the unavailable state if the station is not available.
if (!this.isAvailable) {
this.setFeedbackImage(this.unavailableTemplatePath, {
...replacements,
state: "unavailable",
Expand All @@ -247,8 +256,11 @@ export class StationVolumeController extends BaseController {
}

private refreshTitle(): void {
// Set the unavilable state if the station is not available.
if (this.isAvailable !== undefined && !this.isAvailable) {
if (
!trackAudioManager.isConnected ||
!trackAudioManager.isVoiceConnected ||
!this.isAvailable
) {
this.action
.setFeedback({
title: {
Expand All @@ -269,7 +281,7 @@ export class StationVolumeController extends BaseController {
return;
}

// Nomral connected state.
// Normal connected state.
this.action
.setFeedback({
title: {
Expand Down