From 72ff1c101535e6831b917ea0c9b23c603ade5b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 12 Jan 2024 11:15:47 +0100 Subject: [PATCH] feat(external-api) add transcribingStatusChanged event --- modules/API/API.js | 13 +++++++++++++ modules/API/external/external_api.js | 1 + react/features/transcribing/middleware.ts | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/modules/API/API.js b/modules/API/API.js index 77a77c15d36f..c784369fff48 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -1975,6 +1975,19 @@ class API { }); } + /** + * Notify external application (if API is enabled) that transcribing has started or stopped. + * + * @param {boolean} on - True if transcribing is on, false otherwise. + * @returns {void} + */ + notifyTranscribingStatusChanged(on) { + this._sendEvent({ + name: 'transcribing-status-changed', + on + }); + } + /** * Notify external application (if API is enabled) that the user received * a transcription chunk. diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index 002fc0742537..ce9807021837 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -160,6 +160,7 @@ const events = { 'suspend-detected': 'suspendDetected', 'tile-view-changed': 'tileViewChanged', 'toolbar-button-clicked': 'toolbarButtonClicked', + 'transcribing-status-changed': 'transcribingStatusChanged', 'transcription-chunk-received': 'transcriptionChunkReceived', 'whiteboard-status-changed': 'whiteboardStatusChanged' }; diff --git a/react/features/transcribing/middleware.ts b/react/features/transcribing/middleware.ts index 49acf03785ae..1638b8253745 100644 --- a/react/features/transcribing/middleware.ts +++ b/react/features/transcribing/middleware.ts @@ -38,6 +38,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => { switch (action.type) { case _TRANSCRIBER_JOINED: { + notifyTranscribingStatusChanged(true); dispatch(showStartedTranscribingNotification()); const state = getState(); @@ -50,6 +51,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => { break; } case _TRANSCRIBER_LEFT: { + notifyTranscribingStatusChanged(false); dispatch(showStoppedTranscribingNotification()); const state = getState(); @@ -83,7 +85,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => { break; } - case SET_REQUESTING_SUBTITLES: if (action.enabled && !isTranscribing) { dispatch(showPendingTranscribingNotification()); @@ -95,3 +96,15 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => { return next(action); }); + +/** + * Notify external application (if API is enabled) that transcribing has started or stopped. + * + * @param {boolean} on - True if transcribing is on, false otherwise. + * @returns {void} + */ +function notifyTranscribingStatusChanged(on: boolean) { + if (typeof APP !== 'undefined') { + APP.API.notifyTranscribingStatusChanged(on); + } +}