Skip to content

Commit ad5f211

Browse files
committed
Reduce code duplication again
1 parent fb98e92 commit ad5f211

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

src/embedded.ts

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -478,51 +478,23 @@ export class RoomWidgetClient extends MatrixClient {
478478
*/
479479
// eslint-disable-next-line
480480
public async _unstable_cancelScheduledDelayedEvent(delayId: string): Promise<EmptyObject> {
481-
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
482-
throw new UnsupportedDelayedEventsEndpointError(
483-
"Server does not support the delayed events API",
484-
"cancelScheduledDelayedEvent",
485-
);
486-
}
487-
488-
await this.widgetApi
489-
.updateDelayedEvent(delayId, UpdateDelayedEventAction.Cancel)
490-
.catch(timeoutToConnectionError);
491-
return {};
481+
return this._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Cancel);
492482
}
493483

494484
/**
495485
* @experimental This currently relies on an unstable MSC (MSC4140).
496486
*/
497487
// eslint-disable-next-line
498488
public async _unstable_restartScheduledDelayedEvent(delayId: string): Promise<EmptyObject> {
499-
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
500-
throw new UnsupportedDelayedEventsEndpointError(
501-
"Server does not support the delayed events API",
502-
"restartScheduledDelayedEvent",
503-
);
504-
}
505-
506-
await this.widgetApi
507-
.updateDelayedEvent(delayId, UpdateDelayedEventAction.Restart)
508-
.catch(timeoutToConnectionError);
509-
return {};
489+
return this._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Restart);
510490
}
511491

512492
/**
513493
* @experimental This currently relies on an unstable MSC (MSC4140).
514494
*/
515495
// eslint-disable-next-line
516496
public async _unstable_sendScheduledDelayedEvent(delayId: string): Promise<EmptyObject> {
517-
if (!(await this.doesServerSupportUnstableFeature(UNSTABLE_MSC4140_DELAYED_EVENTS))) {
518-
throw new UnsupportedDelayedEventsEndpointError(
519-
"Server does not support the delayed events API",
520-
"sendScheduledDelayedEvent",
521-
);
522-
}
523-
524-
await this.widgetApi.updateDelayedEvent(delayId, UpdateDelayedEventAction.Send).catch(timeoutToConnectionError);
525-
return {};
497+
return this._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Send);
526498
}
527499

528500
/**

0 commit comments

Comments
 (0)