Skip to content

Commit

Permalink
feat(external-api) add transcribingStatusChanged event
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Jan 12, 2024
1 parent 6128292 commit 72ff1c1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions modules/API/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions modules/API/external/external_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
Expand Down
15 changes: 14 additions & 1 deletion react/features/transcribing/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {

switch (action.type) {
case _TRANSCRIBER_JOINED: {
notifyTranscribingStatusChanged(true);
dispatch(showStartedTranscribingNotification());

const state = getState();
Expand All @@ -50,6 +51,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
break;
}
case _TRANSCRIBER_LEFT: {
notifyTranscribingStatusChanged(false);
dispatch(showStoppedTranscribingNotification());

const state = getState();
Expand Down Expand Up @@ -83,7 +85,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {

break;
}

case SET_REQUESTING_SUBTITLES:
if (action.enabled && !isTranscribing) {
dispatch(showPendingTranscribingNotification());
Expand All @@ -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);
}
}

0 comments on commit 72ff1c1

Please sign in to comment.