Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
/ js-client Public archive

fix(#325): toActionable method is falling on error Cannot read properties of undefined (reading 'substr') #327

Merged
merged 3 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/models/actionable/raw-actionable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ export interface RawActionableAction {
command: RawActionableCommand;
}

export interface RawActionableTrigger {
pattern: string;
hyperlink: boolean;
}
/**
* An Actionable trigger can be a single string or the object below.
*/
export type RawActionableTrigger =
| {
pattern: string;
hyperlink: boolean;
}
| string;

export type RawActionableTimeVariable =
| { type: 'timestamp'; format: null | string; placeholder: null | string }
Expand Down
4 changes: 2 additions & 2 deletions src/models/actionable/to-actionable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const toActionable = (raw: RawActionable): Actionable => ({
});

export const toActionableTrigger = (raw: RawActionableTrigger): ActionableTrigger => ({
pattern: toRegex(raw.pattern),
activatesOn: raw.hyperlink ? 'clicks and selection' : 'selection',
pattern: isString(raw) ? toRegex(raw) : toRegex(raw.pattern),
activatesOn: isString(raw) || raw.pattern ? 'clicks and selection' : 'selection',
});

export const toActionableAction = (raw: RawActionableAction): ActionableAction => ({
Expand Down