2020-05-20 10:57:03 +00:00
|
|
|
import {
|
|
|
|
HIDDEN_PARTICIPANT_JOINED,
|
|
|
|
HIDDEN_PARTICIPANT_LEFT,
|
|
|
|
PARTICIPANT_UPDATED
|
2022-10-26 06:59:21 +00:00
|
|
|
} from '../base/participants/actionTypes';
|
|
|
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
|
|
|
import { toggleRequestingSubtitles } from '../subtitles/actions.any';
|
|
|
|
|
2018-07-26 16:33:40 +00:00
|
|
|
import {
|
2022-06-28 11:11:26 +00:00
|
|
|
_TRANSCRIBER_JOINED,
|
2019-04-16 19:27:17 +00:00
|
|
|
_TRANSCRIBER_LEFT
|
2018-07-26 16:33:40 +00:00
|
|
|
} from './actionTypes';
|
|
|
|
import {
|
|
|
|
hidePendingTranscribingNotification,
|
|
|
|
potentialTranscriberJoined,
|
|
|
|
showStoppedTranscribingNotification,
|
|
|
|
transcriberJoined,
|
|
|
|
transcriberLeft
|
|
|
|
} from './actions';
|
|
|
|
|
|
|
|
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(store => next => action => {
|
|
|
|
const {
|
|
|
|
transcriberJID,
|
|
|
|
potentialTranscriberJIDs
|
|
|
|
} = store.getState()['features/transcribing'];
|
|
|
|
|
|
|
|
switch (action.type) {
|
2022-06-28 11:11:26 +00:00
|
|
|
case _TRANSCRIBER_LEFT: {
|
2018-07-26 16:33:40 +00:00
|
|
|
store.dispatch(showStoppedTranscribingNotification());
|
2022-06-28 11:11:26 +00:00
|
|
|
const state = store.getState();
|
|
|
|
const { transcription } = state['features/base/config'];
|
|
|
|
const { _requestingSubtitles } = state['features/subtitles'];
|
|
|
|
|
|
|
|
if (_requestingSubtitles && !transcription?.disableStartForAll) {
|
|
|
|
store.dispatch(toggleRequestingSubtitles());
|
|
|
|
}
|
2018-07-26 16:33:40 +00:00
|
|
|
break;
|
2022-06-28 11:11:26 +00:00
|
|
|
}
|
2018-07-26 16:33:40 +00:00
|
|
|
case HIDDEN_PARTICIPANT_JOINED:
|
|
|
|
if (action.displayName
|
|
|
|
&& action.displayName === TRANSCRIBER_DISPLAY_NAME) {
|
|
|
|
store.dispatch(transcriberJoined(action.id));
|
|
|
|
} else {
|
|
|
|
store.dispatch(potentialTranscriberJoined(action.id));
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case HIDDEN_PARTICIPANT_LEFT:
|
|
|
|
if (action.id === transcriberJID) {
|
|
|
|
store.dispatch(transcriberLeft(action.id));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PARTICIPANT_UPDATED: {
|
|
|
|
const { participant } = action;
|
|
|
|
|
|
|
|
if (potentialTranscriberJIDs.includes(participant.id)
|
|
|
|
&& participant.name === TRANSCRIBER_DISPLAY_NAME) {
|
|
|
|
store.dispatch(transcriberJoined(participant.id));
|
|
|
|
store.dispatch(hidePendingTranscribingNotification());
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2022-06-28 11:11:26 +00:00
|
|
|
case _TRANSCRIBER_JOINED: {
|
|
|
|
const state = store.getState();
|
|
|
|
const { transcription } = state['features/base/config'];
|
|
|
|
const { _requestingSubtitles } = state['features/subtitles'];
|
|
|
|
|
|
|
|
if (!_requestingSubtitles && !transcription?.disableStartForAll) {
|
|
|
|
store.dispatch(toggleRequestingSubtitles());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2018-07-26 16:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return next(action);
|
|
|
|
});
|