Skip to content

Commit

Permalink
Merge pull request #15 from neilenns/neilenns/issue14
Browse files Browse the repository at this point in the history
Only update button transmission state if it actually changed
  • Loading branch information
neilenns authored May 14, 2024
2 parents cb8081b + cfde095 commit 965a27d
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions src/actionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class TrackAudioAction {
listenTo: ListenTo;
action: Action;
frequency: number = 0;
isRx: boolean = false;
isTx: boolean = false;

constructor(callsign: string, listenTo: ListenTo, action: Action) {
this.callsign = callsign;
Expand Down Expand Up @@ -81,11 +83,15 @@ export default class ActionManager extends EventEmitter {
public rxBegin(frequency: number) {
this.actions
.filter(
(entry) => entry.frequency === frequency && entry.listenTo === "rx"
(entry) =>
entry.frequency === frequency &&
entry.listenTo === "rx" &&
entry.isRx === false
)
.forEach((entry) =>
entry.action.setImage("images/actions/station-status/orange.svg")
);
.forEach((entry) => {
entry.action.setImage("images/actions/station-status/orange.svg");
entry.isRx = true;
});
}

/**
Expand All @@ -95,9 +101,15 @@ export default class ActionManager extends EventEmitter {
public rxEnd(frequency: number) {
this.actions
.filter(
(entry) => entry.frequency === frequency && entry.listenTo === "rx"
(entry) =>
entry.frequency === frequency &&
entry.listenTo === "rx" &&
entry.isRx === true
)
.forEach((entry) => entry.action.setImage());
.forEach((entry) => {
entry.action.setImage();
entry.isRx = false;
});
}

/**
Expand All @@ -107,11 +119,15 @@ export default class ActionManager extends EventEmitter {
public txBegin(frequency: number) {
this.actions
.filter(
(entry) => entry.frequency === frequency && entry.listenTo === "tx"
(entry) =>
entry.frequency === frequency &&
entry.listenTo === "tx" &&
entry.isTx === false
)
.forEach((entry) =>
entry.action.setImage("images/actions/station-status/orange.svg")
);
.forEach((entry) => {
entry.action.setImage("images/actions/station-status/orange.svg");
entry.isTx = true;
});
}

/**
Expand All @@ -121,9 +137,15 @@ export default class ActionManager extends EventEmitter {
public txEnd(frequency: number) {
this.actions
.filter(
(entry) => entry.frequency === frequency && entry.listenTo === "tx"
(entry) =>
entry.frequency === frequency &&
entry.listenTo === "tx" &&
entry.isTx === true
)
.forEach((entry) => entry.action.setImage());
.forEach((entry) => {
entry.action.setImage();
entry.isTx = false;
});
}

/**
Expand Down

0 comments on commit 965a27d

Please sign in to comment.