Skip to content

Commit

Permalink
Set dial indicators to grey when not connected
Browse files Browse the repository at this point in the history
Fixes #374
  • Loading branch information
neilenns committed Jan 12, 2025
1 parent 44e9c0f commit de3364c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 35 deletions.
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"
]
}
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,15 @@
"editor.formatOnSave": false
},
"svg.preview.background": "editor",
"cSpell.words": ["elgato", "streamdeck"]
"cSpell.words": [
"Autopurge",
"Callsign",
"callsigns",
"coms",
"elgato",
"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.
4 changes: 2 additions & 2 deletions src/controllers/mainVolume.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MainVolumeSettings } from "@actions/mainVolume";
import { DialAction } from "@elgato/streamdeck";
import { Controller } from "@interfaces/controller";
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 +57,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
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
32 changes: 21 additions & 11 deletions src/controllers/stationVolume.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 { 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 +21,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 +75,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 +223,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 (this.isAvailable === undefined) {
this.setFeedbackImage(this.unavailableTemplatePath, {
...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 +255,10 @@ export class StationVolumeController extends BaseController {
}

private refreshTitle(): void {
// Set the unavilable state if the station is not available.
if (this.isAvailable !== undefined && !this.isAvailable) {
// Set the unavailable state if the station is not available.
// If TrackAudio voice isn't connected isAvailable is undefined
// and things get shown in the same state.
if (this.isAvailable === undefined || !this.isAvailable) {
this.action
.setFeedback({
title: {
Expand All @@ -269,7 +279,7 @@ export class StationVolumeController extends BaseController {
return;
}

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

0 comments on commit de3364c

Please sign in to comment.