diff --git a/client/web/divkit/src/components/Root.svelte b/client/web/divkit/src/components/Root.svelte index 16549fe00..c2c711a84 100644 --- a/client/web/divkit/src/components/Root.svelte +++ b/client/web/divkit/src/components/Root.svelte @@ -1123,6 +1123,19 @@ callHideTooltip(actionTyped.id, componentContext); break; } + case 'timer': { + if (timersController) { + timersController.execTimerAction(actionTyped.id, actionTyped.action); + } else { + log(wrapError(new Error('Incorrect timer action'), { + additional: { + id: actionTyped.id, + action: actionTyped.action + } + })); + } + break; + } default: { log(wrapError(new Error('Unknown type of action'), { additional: { diff --git a/client/web/divkit/src/utils/timers.ts b/client/web/divkit/src/utils/timers.ts index 576c88a06..dc0ae3704 100644 --- a/client/web/divkit/src/utils/timers.ts +++ b/client/web/divkit/src/utils/timers.ts @@ -101,7 +101,7 @@ export class TimersController { }); } - execTimerAction(id: string | null, action: string | null) { + execTimerAction(id: string | null | undefined, action: string | null | undefined) { if (!id || !action || !this.timers.has(id) || !AVAIL_ACTIONS.has(action)) { this.logError(wrapError(new Error('Incorrect timer action'), { additional: { diff --git a/client/web/divkit/typings/common.d.ts b/client/web/divkit/typings/common.d.ts index 20a0e7e27..cfeb8de5f 100644 --- a/client/web/divkit/typings/common.d.ts +++ b/client/web/divkit/typings/common.d.ts @@ -239,9 +239,15 @@ export interface ActionHideTooltip { id: string; } +export interface ActionTimer { + type: 'timer'; + id: string; + action: 'start' | 'stop' | 'pause' | 'resume' | 'cancel' | 'reset'; +} + export type TypedAction = ActionSetVariable | ActionArrayRemoveValue | ActionArrayInsertValue | ActionCopyToClipboard | ActionFocusElement | ActionClearFocus | ActionDictSetValue | ActionArraySetValue | - ActionAnimatorStart | ActionAnimatorStop | ActionShowTooltip | ActionHideTooltip; + ActionAnimatorStart | ActionAnimatorStop | ActionShowTooltip | ActionHideTooltip | ActionTimer; export interface ActionBase { log_id: string; diff --git a/schema/div-action-timer.json b/schema/div-action-timer.json index a1d80ce08..2ef510511 100644 --- a/schema/div-action-timer.json +++ b/schema/div-action-timer.json @@ -27,7 +27,8 @@ }, "platforms": [ "android", - "ios" + "ios", + "web" ], "required": [ "type", diff --git a/test_data/regression_test_data/index.json b/test_data/regression_test_data/index.json index 67131a7a7..5570379c0 100644 --- a/test_data/regression_test_data/index.json +++ b/test_data/regression_test_data/index.json @@ -2120,7 +2120,8 @@ ], "platforms": [ "android", - "ios" + "ios", + "web" ], "expected_results": [ "The timer calls tick_actions and changes the variable with the set interval.",