-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor action.ts Fixes #55 * Fix build breaks
- Loading branch information
Showing
24 changed files
with
255 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,35 @@ | ||
{ | ||
/* Prefer tabs over spaces for accessibility */ | ||
"editor.insertSpaces": false, | ||
"editor.detectIndentation": false, | ||
/* Explorer */ | ||
"explorer.fileNesting.enabled": true, | ||
"explorer.fileNesting.patterns": { | ||
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts", | ||
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, rollup.config.mjs, tsconfig.json", | ||
"eslint.config.js": ".markdownlint.jsonc", | ||
"README.md": "DEVELOPMENT.md" | ||
}, | ||
"files.exclude": { | ||
"node_modules": true, | ||
"com.neil-enns.vatis.streamDeckPlugin": true, | ||
}, | ||
"eslint.useFlatConfig": true, | ||
"git.enableSmartCommit": true, | ||
"[svg]": { | ||
/* Prefer tabs over spaces for accessibility */ | ||
"editor.insertSpaces": false, | ||
"editor.detectIndentation": false, | ||
/* Explorer */ | ||
"explorer.fileNesting.enabled": true, | ||
"explorer.fileNesting.patterns": { | ||
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts", | ||
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, rollup.config.mjs, tsconfig.json", | ||
"eslint.config.js": ".markdownlint.jsonc", | ||
"README.md": "DEVELOPMENT.md" | ||
}, | ||
"files.exclude": { | ||
"node_modules": true, | ||
"com.neil-enns.vatis.streamDeckPlugin": true | ||
}, | ||
"eslint.useFlatConfig": true, | ||
"git.enableSmartCommit": true, | ||
"[svg]": { | ||
"editor.formatOnSave": false | ||
}, | ||
"cSpell.words": [ | ||
"Addv", | ||
"Atis", | ||
"atisletter", | ||
"elgato", | ||
"getv", | ||
"handlev", | ||
"streamdeck", | ||
"Typeguard", | ||
"Updatev", | ||
"vatis", | ||
"vatisstatus" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { AtisLetterSettings } from "@actions/atisLetter"; | ||
import { AtisLetterController } from "@controllers/atisLetter"; | ||
import { KeyAction } from "@elgato/streamdeck"; | ||
import actionManager from "@managers/action"; | ||
|
||
/** | ||
* Adds an atis letter action to the action list. Emits an atisLetterAdded | ||
* event after the action is added. | ||
* @param action The action | ||
* @param settings The settings for the action | ||
*/ | ||
export const handleAddAtisLetter = ( | ||
action: KeyAction, | ||
settings: AtisLetterSettings | ||
) => { | ||
const controller = new AtisLetterController(action, settings); | ||
|
||
actionManager.add(controller); | ||
actionManager.emit("atisLetterAdded", controller); | ||
actionManager.emit("actionAdded", controller); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import vAtisManager from "@managers/vatis"; | ||
|
||
/** | ||
* Called when an ATIS letter action has a long press. Clears the new | ||
* ATIS state on all stations. | ||
* @param actionId The ID of the action that had the long press | ||
*/ | ||
export const handleAtisLetterLongPress = () => { | ||
vAtisManager.sendMessage({ type: "acknowledgeAtisUpdate" }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { KeyAction } from "@elgato/streamdeck"; | ||
import actionManager from "@managers/action"; | ||
import vAtisManager from "@managers/vatis"; | ||
|
||
/** | ||
* Called when an ATIS letter action has a short press. Clears the state. | ||
* @param actionId The ID of the action that had the short press | ||
*/ | ||
export const handleAtisLetterShortPress = (action: KeyAction) => { | ||
const savedAction = actionManager | ||
.getAtisLetterControllers() | ||
.find((entry) => entry.action.id === action.id); | ||
|
||
if (!savedAction?.station) { | ||
return; | ||
} | ||
|
||
// Send a clear request to vATIS | ||
vAtisManager.sendMessage({ | ||
type: "acknowledgeAtisUpdate", | ||
value: { | ||
station: savedAction.station, | ||
atisType: savedAction.atisType, | ||
}, | ||
}); | ||
}; |
33 changes: 33 additions & 0 deletions
33
src/events/streamdeck/atisLetter/updateAtisLetterSettings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { AtisLetterSettings } from "@actions/atisLetter"; | ||
import { KeyAction } from "@elgato/streamdeck"; | ||
import actionManager from "@managers/action"; | ||
|
||
/** | ||
* Updates the settings associated with an ATIS letter status action. | ||
* Emits a atisLetterUpdated event if the settings require | ||
* the action to refresh. | ||
* @param action The action to update | ||
* @param settings The new settings to use | ||
*/ | ||
export const handleUpdateAtisLetterSettings = ( | ||
action: KeyAction, | ||
settings: AtisLetterSettings | ||
) => { | ||
const savedAction = actionManager | ||
.getAtisLetterControllers() | ||
.find((entry) => entry.action.id === action.id); | ||
|
||
if (!savedAction) { | ||
return; | ||
} | ||
|
||
const requiresRefresh = | ||
savedAction.settings.station !== settings.station || | ||
savedAction.settings.atisType !== settings.atisType; | ||
|
||
savedAction.settings = settings; | ||
|
||
if (requiresRefresh) { | ||
actionManager.emit("atisLetterUpdated", savedAction); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ActionContext } from "@elgato/streamdeck"; | ||
import actionManager from "@managers/action"; | ||
|
||
/** | ||
* Removes an action from the list. Emits a removed event after the action is removed. | ||
* @param action The action to remove | ||
*/ | ||
export const handleRemove = (action: ActionContext) => { | ||
actionManager.remove(action); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { vAtisStatusSettings } from "@actions/vAtisStatus"; | ||
import { vAtisStatusController } from "@controllers/vAtisStatus"; | ||
import { KeyAction } from "@elgato/streamdeck"; | ||
import actionManager from "@managers/action"; | ||
|
||
/** | ||
* Adds a vATIS status action to the action list. Emits a vAtisStatusAdded event | ||
* after the action is added. | ||
* @param action The action to add | ||
*/ | ||
export const handleAddvAtisStatus = ( | ||
action: KeyAction, | ||
settings: vAtisStatusSettings | ||
) => { | ||
const controller = new vAtisStatusController(action, settings); | ||
|
||
actionManager.add(controller); | ||
actionManager.emit("vAtisStatusAdded", controller); | ||
actionManager.emit("actionAdded", controller); | ||
}; |
23 changes: 23 additions & 0 deletions
23
src/events/streamdeck/vAtisStatus/updatevAtisStatusSettings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { vAtisStatusSettings } from "@actions/vAtisStatus"; | ||
import { KeyAction } from "@elgato/streamdeck"; | ||
import actionManager from "@managers/action"; | ||
|
||
/** | ||
* Updates the settings associated with a vATIS status action. | ||
* @param action The action to update | ||
* @param settings The new settings to use | ||
*/ | ||
export const handleUpdatevAtisStatusSettings = ( | ||
action: KeyAction, | ||
settings: vAtisStatusSettings | ||
) => { | ||
const savedAction = actionManager | ||
.getvAtisStatusControllers() | ||
.find((entry) => entry.action.id === action.id); | ||
|
||
if (!savedAction) { | ||
return; | ||
} | ||
|
||
savedAction.settings = settings; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { KeyAction } from "@elgato/streamdeck"; | ||
import actionManager from "@managers/action"; | ||
import vAtisManager from "@managers/vatis"; | ||
import { handleAsyncException } from "@utils/handleAsyncException"; | ||
|
||
/** | ||
* Called when a vATIS status action has a long press. Refreshes all | ||
* ATIS actions. | ||
* @param actionId The ID of the action that had the long press | ||
*/ | ||
export const handlevAtisStatusLongPress = (action: KeyAction) => { | ||
actionManager.getAtisLetterControllers().forEach((entry) => { | ||
entry.reset(); | ||
}); | ||
|
||
// Refresh all the stations. | ||
vAtisManager.refreshAtis(); | ||
|
||
action.showOk().catch((error: unknown) => { | ||
handleAsyncException("Unable to show OK on ATIS button:", error); | ||
}); | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.