Skip to content

Commit dd76856

Browse files
General cleanup.
1 parent 51f2be1 commit dd76856

File tree

6 files changed

+373
-255
lines changed

6 files changed

+373
-255
lines changed

src/actions.ts

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,65 @@ export function UpdateActions(self: ModuleInstance): void {
44
self.setActionDefinitions({
55
play_action: {
66
name: 'Play',
7-
options: [
8-
],
9-
// callback: async (event) => {
7+
options: [],
8+
// callback: async (event) => {
109
callback: async () => {
11-
self.sendCommand('Play');
10+
self.sendCommand('Play')
1211
},
1312
},
1413
stop_action: {
1514
name: 'Stop',
16-
options: [
17-
],
15+
options: [],
1816
callback: async () => {
19-
self.sendCommand('Stop');
17+
self.sendCommand('Stop')
2018
},
2119
},
2220
previous_action: {
2321
name: 'Previous',
24-
options: [
25-
],
22+
options: [],
2623
callback: async () => {
27-
self.sendCommand('Previous');
24+
self.sendCommand('Previous')
2825
},
2926
},
3027
next_action: {
3128
name: 'Next',
32-
options: [
33-
],
29+
options: [],
3430
callback: async () => {
35-
self.sendCommand('Next');
31+
self.sendCommand('Next')
3632
},
3733
},
3834
pause_action: {
3935
name: 'Pause',
40-
options: [
41-
],
36+
options: [],
4237
callback: async () => {
43-
self.sendCommand('Pause');
38+
self.sendCommand('Pause')
4439
},
4540
},
4641
cue_action: {
4742
name: 'Cue',
48-
options: [
49-
],
43+
options: [],
5044
callback: async () => {
51-
self.sendCommand('Cue');
45+
self.sendCommand('Cue')
5246
},
5347
},
5448
updateStatus_action: {
5549
name: 'Status',
56-
options: [
57-
],
50+
options: [],
5851
callback: async () => {
59-
self.requestCommand('Status')
60-
.then(response => {
52+
self.requestCommand('Status').then(
53+
(response) => {
6154
self.log('info', `status is ${response.data.Status}`)
6255
self.setVariableValues({
6356
channelStatus: response.data.Status,
64-
channelName: response.data.Name
57+
channelName: response.data.Name,
6558
})
66-
self.checkFeedbacks('insightStatusPlay', 'insightStatusCue', 'insightStatusStop');
67-
})
59+
self.checkFeedbacks('insightStatusPlay', 'insightStatusCue', 'insightStatusStop')
60+
},
61+
(_reject) => {
62+
self.log('error', 'Status action failed.')
63+
},
64+
)
6865
},
6966
},
7067
})
7168
}
72-

src/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Regex, type SomeCompanionConfigField } from '@companion-module/base'
22

33
export interface ModuleConfig {
4-
host: string
5-
authToken: string
6-
channelID: number
7-
refreshPeriod: number,
4+
host: string
5+
authToken: string
6+
channelID: number
7+
refreshPeriod: number
88
}
99

1010
export function GetConfigFields(): SomeCompanionConfigField[] {
@@ -21,7 +21,7 @@ export function GetConfigFields(): SomeCompanionConfigField[] {
2121
id: 'authToken',
2222
label: 'Authorization Key',
2323
width: 400,
24-
default: ''
24+
default: '',
2525
},
2626
{
2727
type: 'number',

src/feedbacks.ts

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,67 @@ import type { ModuleInstance } from './main.js'
44

55
export function UpdateFeedbacks(self: ModuleInstance): void {
66
self.setFeedbackDefinitions({
7-
'insightStatusDisconnected': getChannelStatusFeedback('insightStatusDisconnected', 'Disconnected', self),
8-
'insightStatusPlay': getChannelStatusFeedback('insightStatusPlay', 'Playing', self),
9-
'insightStatusCue': getChannelStatusFeedback('insightStatusCue', 'Cued', self),
10-
'insightStatusStop': getChannelStatusFeedback('insightStatusStop', 'Stopped', self),
11-
'insightChannelName': getChannelNameFeedback('insightChannelName', self)
7+
insightStatusDisconnected: getChannelStatusFeedback('insightStatusDisconnected', 'Disconnected', self),
8+
insightStatusPlay: getChannelStatusFeedback('insightStatusPlay', 'Playing', self),
9+
insightStatusCue: getChannelStatusFeedback('insightStatusCue', 'Cued', self),
10+
insightStatusStop: getChannelStatusFeedback('insightStatusStop', 'Stopped', self),
11+
insightChannelName: getChannelNameFeedback('insightChannelName', self),
1212
})
1313
}
1414

15-
function getChannelStatusFeedback(name: string, state : string, self: ModuleInstance): CompanionBooleanFeedbackDefinition
16-
{
15+
function getChannelStatusFeedback(
16+
name: string,
17+
state: string,
18+
self: ModuleInstance,
19+
): CompanionBooleanFeedbackDefinition {
1720
return {
1821
type: 'boolean',
1922
name: name,
2023
description: '',
2124
defaultStyle: {
2225
bgcolor: combineRgb(255, 255, 255),
23-
color: combineRgb(0, 0, 0),
26+
color: combineRgb(0, 0, 0),
2427
},
2528
options: [
26-
{
27-
type: 'textinput',
28-
label: 'text',
29-
id: 'text',
30-
default: '',
31-
useVariables: true
32-
}
29+
{
30+
type: 'textinput',
31+
label: 'text',
32+
id: 'text',
33+
default: '',
34+
useVariables: true,
35+
},
3336
],
34-
callback: (feedback, context) => {
35-
return new Promise((resolve, reject) => {
36-
reject;
37-
feedback;
38-
context;
39-
var val = self.getVariableValue('channelStatus') as string;
40-
resolve(val == state);
37+
callback: async (_feedback, _context) => {
38+
return new Promise((resolve, _reject) => {
39+
const val = self.getVariableValue('channelStatus') as string
40+
resolve(val == state)
4141
})
42-
}
42+
},
4343
}
4444
}
4545

46-
function getChannelNameFeedback(name: string, self: ModuleInstance): CompanionBooleanFeedbackDefinition
47-
{
46+
function getChannelNameFeedback(name: string, _self: ModuleInstance): CompanionBooleanFeedbackDefinition {
4847
return {
4948
type: 'boolean',
5049
name: name,
5150
description: '',
5251
defaultStyle: {
5352
bgcolor: combineRgb(255, 255, 255),
54-
color: combineRgb(0, 0, 0),
53+
color: combineRgb(0, 0, 0),
5554
},
5655
options: [
57-
{
58-
type: 'textinput',
59-
label: 'text',
60-
id: 'text',
61-
default: '',
62-
useVariables: true
63-
}
56+
{
57+
type: 'textinput',
58+
label: 'text',
59+
id: 'text',
60+
default: '',
61+
useVariables: true,
62+
},
6463
],
65-
callback: (feedback, context) => {
66-
return new Promise((resolve, reject) => {
67-
feedback;
68-
context;
69-
resolve;
70-
reject;
71-
self;
72-
return true; // always returns true because notification is sent on name change only.
64+
callback: async (_feedback, _context) => {
65+
return new Promise((_resolve, _reject) => {
66+
return true // always returns true because notification is sent on name change only.
7367
})
74-
}
68+
},
7569
}
7670
}

0 commit comments

Comments
 (0)