123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- // @flow
-
- import {
- NOTIFICATION_TIMEOUT,
- hideNotification,
- showErrorNotification,
- showNotification
- } from '../notifications';
-
- import {
- _POTENTIAL_TRANSCRIBER_JOINED,
- _TRANSCRIBER_JOINED,
- _TRANSCRIBER_LEFT,
- SET_PENDING_TRANSCRIBING_NOTIFICATION_UID
- } from './actionTypes';
-
- /**
- * Notify that the transcriber, with a unique ID, has joined.
- *
- * @param {string} participantId - The participant id of the transcriber.
- * @returns {{
- * type: _TRANSCRIBER_JOINED,
- * participantId: string
- * }}
- */
- export function transcriberJoined(participantId: string) {
- return {
- type: _TRANSCRIBER_JOINED,
- transcriberJID: participantId
- };
- }
-
- /**
- * Notify that the transcriber, with a unique ID, has left.
- *
- * @param {string} participantId - The participant id of the transcriber.
- * @returns {{
- * type: _TRANSCRIBER_LEFT,
- * participantId: string
- * }}
- */
- export function transcriberLeft(participantId: string) {
- return {
- type: _TRANSCRIBER_LEFT,
- transcriberJID: participantId
- };
- }
-
- /**
- * Notify that a potential transcriber, with a unique ID, has joined.
- *
- * @param {string} participantId - The participant id of the transcriber.
- * @returns {{
- * type: _POTENTIAL_TRANSCRIBER_JOINED,
- * participantId: string
- * }}
- */
- export function potentialTranscriberJoined(participantId: string) {
- return {
- type: _POTENTIAL_TRANSCRIBER_JOINED,
- transcriberJID: participantId
- };
- }
-
- /**
- * Signals that the pending transcribing notification should be shown on the
- * screen.
- *
- * @returns {Function}
- */
- export function showPendingTranscribingNotification() {
- return async (dispatch: Function) => {
- const notification = await dispatch(showNotification({
- descriptionKey: 'transcribing.pending',
- isDismissAllowed: false,
- titleKey: 'dialog.transcribing'
- }));
-
- if (notification) {
- dispatch(setPendingTranscribingNotificationUid(notification.uid));
- }
- };
- }
-
- /**
- * Sets UID of the the pending transcribing notification to use it when hiding
- * the notification is necessary, or unsets it when undefined (or no param) is
- * passed.
- *
- * @param {?number} uid - The UID of the notification.
- * @returns {{
- * type: SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
- * uid: number
- * }}
- */
- export function setPendingTranscribingNotificationUid(uid: ?number) {
- return {
- type: SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
- uid
- };
- }
-
- /**
- * Signals that the pending transcribing notification should be removed from the
- * screen.
- *
- * @returns {Function}
- */
- export function hidePendingTranscribingNotification() {
- return (dispatch: Function, getState: Function) => {
- const { pendingNotificationUid } = getState()['features/transcribing'];
-
- if (pendingNotificationUid) {
- dispatch(hideNotification(pendingNotificationUid));
- dispatch(setPendingTranscribingNotificationUid());
- }
- };
- }
-
- /**
- * Signals that the stopped transcribing notification should be shown on the
- * screen.
- *
- * @returns {showNotification}
- */
- export function showStoppedTranscribingNotification() {
- return showNotification({
- descriptionKey: 'transcribing.off',
- titleKey: 'dialog.transcribing'
- }, NOTIFICATION_TIMEOUT);
- }
-
-
- /**
- * Signals that the transcribing error notification should be shown.
- *
- * @returns {showErrorNotification}
- */
- export function showTranscribingError() {
- return showErrorNotification({
- descriptionKey: 'transcribing.error',
- titleKey: 'transcribing.failedToStart'
- });
- }
|