Files
jitsi-meet/react/features/transcribing/middleware.ts
Hristo Terezov 05aa48774a feat(recorder-transcription): Handle correctly in the UI.
Until this commit we didn't make difference between transcriptions from the recording dialog and subtitles. Now subtitles are not considered recording anymore and only the transcriptions started from recording dialog are considered recording.
2024-02-27 09:17:24 -06:00

58 lines
1.5 KiB
TypeScript

import {
HIDDEN_PARTICIPANT_JOINED,
HIDDEN_PARTICIPANT_LEFT,
PARTICIPANT_UPDATED
} from '../base/participants/actionTypes';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import {
potentialTranscriberJoined,
transcriberJoined,
transcriberLeft
} from './actions';
import './subscriber';
const TRANSCRIBER_DISPLAY_NAME = 'Transcriber';
/**
* Implements the middleware of the feature transcribing.
*
* @param {Store} store - The redux store.
* @returns {Function}
*/
// eslint-disable-next-line no-unused-vars
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const {
transcriberJID,
potentialTranscriberJIDs
} = getState()['features/transcribing'];
switch (action.type) {
case HIDDEN_PARTICIPANT_JOINED:
if (action.displayName === TRANSCRIBER_DISPLAY_NAME) {
dispatch(transcriberJoined(action.id));
} else {
dispatch(potentialTranscriberJoined(action.id));
}
break;
case HIDDEN_PARTICIPANT_LEFT:
if (action.id === transcriberJID) {
dispatch(transcriberLeft(action.id));
}
break;
case PARTICIPANT_UPDATED: {
const { participant } = action;
if (potentialTranscriberJIDs.includes(participant.id) && participant.name === TRANSCRIBER_DISPLAY_NAME) {
dispatch(transcriberJoined(participant.id));
}
break;
}
}
return next(action);
});