Skip to content

Commit

Permalink
feat: allow specifying 'learn' function timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Nov 27, 2023
1 parent beef8b9 commit d6b2f72
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/host-api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,24 @@ export interface SetActionDefinitionsMessage {
actions: Array<{
id: string
name: string
description?: string
description: string | undefined
options: EncodeIsVisible<SomeCompanionActionInputField>[] // TODO module-lib - versioned types?
hasLearn: boolean
learnTimeout: number | undefined
}>
}

export interface SetFeedbackDefinitionsMessage {
feedbacks: Array<{
id: string
name: string
description?: string
description: string | undefined
options: EncodeIsVisible<SomeCompanionFeedbackInputField>[] // TODO module-lib - versioned types?
type: 'boolean' | 'advanced'
defaultStyle?: Partial<CompanionFeedbackButtonStyleResult>
defaultStyle?: CompanionFeedbackButtonStyleResult
hasLearn: boolean
showInvert: boolean | undefined
learnTimeout: number | undefined
}>
}

Expand Down
1 change: 1 addition & 0 deletions src/internal/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export class ActionManager {
description: action.description,
options: serializeIsVisibleFn(action.options),
hasLearn: !!action.learn,
learnTimeout: action.learnTimeout,
})

// Remember the definition locally
Expand Down
1 change: 1 addition & 0 deletions src/internal/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ export class FeedbackManager {
type: feedback.type,
defaultStyle: feedback.type === 'boolean' ? feedback.defaultStyle : undefined,
hasLearn: !!feedback.learn,
learnTimeout: feedback.learnTimeout,
showInvert: feedback.type === 'boolean' ? feedback.showInvert : false,
})

Expand Down
7 changes: 7 additions & 0 deletions src/module-api/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ export interface CompanionActionDefinition {
action: CompanionActionEvent,
context: CompanionActionContext
) => CompanionOptionValues | undefined | Promise<CompanionOptionValues | undefined>

/**
* Timeout for the 'learn' function (in milliseconds)
* Companion sets a default value of 5s, to ensure that the learn does not get stuck never completing
* You can change this if this number does not work for you, but you should keep it to a sensible value
*/
learnTimeout?: number
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/module-api/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ export interface CompanionFeedbackDefinitionBase {
action: CompanionFeedbackInfo,
context: CompanionFeedbackContext
) => CompanionOptionValues | undefined | Promise<CompanionOptionValues | undefined>

/**
* Timeout for the 'learn' function (in milliseconds)
* Companion sets a default value of 5s, to ensure that the learn does not get stuck never completing
* You can change this if this number does not work for you, but you should keep it to a sensible value
*/
learnTimeout?: number
}

/**
Expand Down

0 comments on commit d6b2f72

Please sign in to comment.