Skip to content

Commit 75813b8

Browse files
authored
Merge pull request #436 from neilenns/issue435
Add a push to mute setting to the volume action
2 parents 72091cd + 4b7224d commit 75813b8

File tree

5 files changed

+62
-4
lines changed

5 files changed

+62
-4
lines changed

com.neil-enns.trackaudio.sdPlugin/pi/stationVolume.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,21 @@
4444
accept="image/png, image/jpeg, image/svg+xml"
4545
></sdpi-file>
4646
</sdpi-item>
47+
48+
<sdpi-item>
49+
<details class="sdpi-item-value">
50+
<summary>Advanced options</summary>
51+
<sdpi-checkbox
52+
setting="pushToMute"
53+
label="Push to toggle mute"
54+
default="true"
55+
></sdpi-checkbox>
56+
<sdpi-checkbox
57+
setting="tapToMute"
58+
label="Tap to toggle mute"
59+
default="true"
60+
></sdpi-checkbox>
61+
</details>
62+
</sdpi-item>
4763
</body>
4864
</html>

src/actions/stationVolume.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class StationVolume extends SingletonAction<StationVolumeSettings> {
6868
return;
6969
}
7070

71-
handleStationVolumeDialPress(ev.action);
71+
handleStationVolumeDialPress(ev.action, "press");
7272
}
7373

7474
override onTouchTap(
@@ -80,7 +80,7 @@ export class StationVolume extends SingletonAction<StationVolumeSettings> {
8080
return;
8181
}
8282

83-
handleStationVolumeDialPress(ev.action);
83+
handleStationVolumeDialPress(ev.action, "tap");
8484
}
8585

8686
override onWillDisappear(
@@ -96,5 +96,7 @@ export interface StationVolumeSettings {
9696
changeAmount?: number;
9797
mutedImagePath?: string;
9898
notMutedImagePath?: string;
99+
pushToMute?: boolean;
100+
tapToMute?: boolean;
99101
[key: string]: JsonValue;
100102
}

src/controllers/stationVolume.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,22 @@ export class StationVolumeController extends BaseController {
145145
this.refreshDisplay();
146146
}
147147

148+
/**
149+
* Gets the pushToMute setting.
150+
* @returns {boolean} True if push to mute is enabled. Defaults to true.
151+
*/
152+
get pushToMute(): boolean {
153+
return this._settings?.pushToMute ?? true;
154+
}
155+
156+
/**
157+
* Gets the tapToMute setting.
158+
* @returns {boolean} True if tap to mute is enabled. Defaults to true.
159+
*/
160+
get tapToMute(): boolean {
161+
return this._settings?.tapToMute ?? true;
162+
}
163+
148164
/**
149165
* Gets the settings.
150166
* @returns {StationVolumeSettings} The settings.

src/events/streamDeck/stationVolume/stationVolumeDialPress.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import { DialAction } from "@elgato/streamdeck";
22
import actionManager from "@managers/action";
33
import trackAudioManager from "@managers/trackAudio";
4+
import mainLogger from "@utils/logger";
5+
6+
const logger = mainLogger.child({ service: "stationVolume" });
47

58
/**
69
* Toggles the mute setting on the station.
710
* @param action The action that triggered the press
811
*/
9-
export const handleStationVolumeDialPress = (action: DialAction) => {
12+
export const handleStationVolumeDialPress = (
13+
action: DialAction,
14+
trigger: "press" | "tap"
15+
) => {
1016
const savedAction = actionManager
1117
.getStationVolumeControllers()
1218
.find((entry) => entry.action.id === action.id);
@@ -15,6 +21,24 @@ export const handleStationVolumeDialPress = (action: DialAction) => {
1521
return;
1622
}
1723

24+
if (!savedAction.pushToMute && trigger === "press") {
25+
logger.info(
26+
`Station volume action ${
27+
savedAction.callsign ?? "undefined"
28+
} does not have push to mute enabled.`
29+
);
30+
return;
31+
}
32+
33+
if (!savedAction.tapToMute && trigger === "tap") {
34+
logger.info(
35+
`Station volume action ${
36+
savedAction.callsign ?? "undefined"
37+
} does not have tap to mute enabled.`
38+
);
39+
return;
40+
}
41+
1842
trackAudioManager.sendMessage({
1943
type: "kSetStationState",
2044
value: {

src/events/vatsim/vatsimDataReceived.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const handleVatsimDataReceived = (data: VatsimData) => {
1414
}
1515

1616
// Look for the callsign in the returned ATIS info. If it's found set the letter.
17-
// If not set the isUnavialable flag to show the error to the user.
17+
// If not set the isUnavailable flag to show the error to the user.
1818
if (action.callsign in atisInfo) {
1919
action.isUnavailable = false;
2020
action.letter = atisInfo[action.callsign].atis_code;

0 commit comments

Comments
 (0)