Files
jitsi-meet/react/features/subtitles/actions.any.ts
Avram Tudor 72b4c8123a ref(transcriptions): refactor transcriptions api (#14144)
* ref(transcriptions): refactor transcriptions api

* ref(transcriptions): refactor usage of translation label

Extend IFrame API to allow adding a transcriber in the room without the subtitles needing to be visible.
Allow transcription chunk messages to be passed through the IFrame API if a transcriber is present.
Clean-up transcription messages sent through the IFrame API to not include timeout field and possible conflicting states (stable / unstable /final)

* fix linting

* code review: extend api message to match webhook format
2023-12-12 14:36:54 +02:00

104 lines
2.7 KiB
TypeScript

import { DEFAULT_LANGUAGE } from '../base/i18n/i18next';
import {
ENDPOINT_MESSAGE_RECEIVED,
REMOVE_TRANSCRIPT_MESSAGE,
SET_REQUESTING_SUBTITLES,
TOGGLE_REQUESTING_SUBTITLES,
UPDATE_TRANSCRIPT_MESSAGE
} from './actionTypes';
/**
* Signals that a participant sent an endpoint message on the data channel.
*
* @param {Object} participant - The participant details sending the message.
* @param {Object} json - The json carried by the endpoint message.
* @returns {{
* type: ENDPOINT_MESSAGE_RECEIVED,
* participant: Object,
* json: Object
* }}
*/
export function endpointMessageReceived(participant: Object, json: Object) {
return {
type: ENDPOINT_MESSAGE_RECEIVED,
participant,
json
};
}
/**
* Signals that a transcript has to be removed from the state.
*
* @param {string} transcriptMessageID - The message_id to be removed.
* @returns {{
* type: REMOVE_TRANSCRIPT_MESSAGE,
* transcriptMessageID: string,
* }}
*/
export function removeTranscriptMessage(transcriptMessageID: string) {
return {
type: REMOVE_TRANSCRIPT_MESSAGE,
transcriptMessageID
};
}
/**
* Signals that a transcript with the given message_id to be added or updated
* is received.
*
* @param {string} transcriptMessageID -The transcript message_id to be updated.
* @param {Object} newTranscriptMessage - The updated transcript message.
* @returns {{
* type: UPDATE_TRANSCRIPT_MESSAGE,
* transcriptMessageID: string,
* newTranscriptMessage: Object
* }}
*/
export function updateTranscriptMessage(transcriptMessageID: string,
newTranscriptMessage: Object) {
return {
type: UPDATE_TRANSCRIPT_MESSAGE,
transcriptMessageID,
newTranscriptMessage
};
}
/**
* Signals that the local user has toggled the ClosedCaption button.
*
* @returns {{
* type: TOGGLE_REQUESTING_SUBTITLES
* }}
*/
export function toggleRequestingSubtitles() {
return {
type: TOGGLE_REQUESTING_SUBTITLES
};
}
/**
* Signals that the local user has enabled or disabled the subtitles.
*
* @param {boolean} enabled - The new state of the subtitles.
* @param {boolean} displaySubtitles - Whether to display subtitles or not.
* @param {string} language - The language of the subtitles.
* @returns {{
* type: SET_REQUESTING_SUBTITLES,
* enabled: boolean,
* displaySubtitles: boolean,
* language: string
* }}
*/
export function setRequestingSubtitles(
enabled: boolean,
displaySubtitles = true,
language: string | null = DEFAULT_LANGUAGE) {
return {
type: SET_REQUESTING_SUBTITLES,
displaySubtitles,
enabled,
language: `translation-languages:${language}`
};
}