2022-09-01 11:00:49 +00:00
|
|
|
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
2022-04-08 12:24:58 +00:00
|
|
|
|
2018-07-26 16:33:40 +00:00
|
|
|
import {
|
2022-09-27 07:10:28 +00:00
|
|
|
SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
|
2018-07-26 16:33:40 +00:00
|
|
|
_POTENTIAL_TRANSCRIBER_JOINED,
|
2022-09-27 07:10:28 +00:00
|
|
|
_TRANSCRIBER_JOINED,
|
|
|
|
_TRANSCRIBER_LEFT
|
2022-04-08 12:24:58 +00:00
|
|
|
} from './actionTypes';
|
2018-07-26 16:33:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns initial state for transcribing feature part of Redux store.
|
|
|
|
*
|
|
|
|
* @returns {{
|
|
|
|
* isTranscribing: boolean,
|
|
|
|
* isDialing: boolean,
|
|
|
|
* transcriberJID: null,
|
|
|
|
* potentialTranscriberJIDs: Array
|
|
|
|
* }}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
function _getInitialState() {
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* Indicates whether there is currently an active transcriber in the
|
2021-11-04 21:10:43 +00:00
|
|
|
* room.
|
2018-07-26 16:33:40 +00:00
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
isTranscribing: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the transcriber has been dialed into the room and
|
2021-11-04 21:10:43 +00:00
|
|
|
* we're currently awaiting successful joining or failure of joining.
|
2018-07-26 16:33:40 +00:00
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
isDialing: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the transcribing feature is in the process of
|
|
|
|
* terminating; the transcriber has been told to leave.
|
|
|
|
*/
|
|
|
|
isTerminating: false,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* The JID of the active transcriber.
|
2018-07-26 16:33:40 +00:00
|
|
|
*
|
|
|
|
* @type { string }
|
|
|
|
*/
|
|
|
|
transcriberJID: null,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* A list containing potential JID's of transcriber participants.
|
2018-07-26 16:33:40 +00:00
|
|
|
*
|
|
|
|
* @type { Array }
|
|
|
|
*/
|
|
|
|
potentialTranscriberJIDs: []
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-09-01 11:00:49 +00:00
|
|
|
export interface ITranscribingState {
|
|
|
|
isDialing: boolean;
|
|
|
|
isTerminating: boolean;
|
|
|
|
isTranscribing: boolean;
|
2022-10-26 06:59:21 +00:00
|
|
|
pendingNotificationUid?: string;
|
2022-09-01 11:00:49 +00:00
|
|
|
potentialTranscriberJIDs: string[];
|
2022-09-08 09:52:36 +00:00
|
|
|
transcriberJID?: string | null;
|
2022-09-01 11:00:49 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 16:33:40 +00:00
|
|
|
/**
|
|
|
|
* Reduces the Redux actions of the feature features/transcribing.
|
|
|
|
*/
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<ITranscribingState>('features/transcribing',
|
|
|
|
(state = _getInitialState(), action): ITranscribingState => {
|
2018-07-26 16:33:40 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case _TRANSCRIBER_JOINED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isTranscribing: true,
|
|
|
|
isDialing: false,
|
|
|
|
transcriberJID: action.transcriberJID
|
|
|
|
};
|
|
|
|
case _TRANSCRIBER_LEFT:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
isTerminating: false,
|
|
|
|
isTranscribing: false,
|
|
|
|
transcriberJID: undefined,
|
|
|
|
potentialTranscriberJIDs: []
|
|
|
|
};
|
|
|
|
case _POTENTIAL_TRANSCRIBER_JOINED:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
potentialTranscriberJIDs:
|
|
|
|
[ action.transcriberJID ]
|
|
|
|
.concat(state.potentialTranscriberJIDs)
|
|
|
|
};
|
|
|
|
case SET_PENDING_TRANSCRIBING_NOTIFICATION_UID:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
pendingNotificationUid: action.uid
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
});
|