Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(transcribing) refactor notification handling

Saúl Ibarra Corretgé6cd876078e09
diff --git a/react/features/notifications/constants.ts b/react/features/notifications/constants.ts
index 0d7a838fcf..996a601c23 100644
--- a/react/features/notifications/constants.ts
+++ b/react/features/notifications/constants.ts
@@ -112,3 +112,10 @@ export const SILENT_JOIN_THRESHOLD = 30;
* Amount of participants beyond which no left notification will be emitted.
*/
export const SILENT_LEFT_THRESHOLD = 30;
+
+/**
+ * The identifier for the transcriber notifications.
+ *
+ * @type {string}
+ */
+export const TRANSCRIBING_NOTIFICATION_ID = 'TRANSCRIBING_NOTIFICATION';
diff --git a/react/features/transcribing/actionTypes.ts b/react/features/transcribing/actionTypes.ts
index df2346f441..f777d23367 100644
--- a/react/features/transcribing/actionTypes.ts
+++ b/react/features/transcribing/actionTypes.ts
@@ -32,17 +32,3 @@ export const _TRANSCRIBER_LEFT = 'TRANSCRIBER_LEFT';
*/
export const _POTENTIAL_TRANSCRIBER_JOINED
= 'POTENTIAL_TRANSCRIBER_JOINED';
-
-/**
- * The type of Redux action which sets the pending transcribing notification UID
- * to use it for when hiding the notification is necessary, or unsets it when
- * undefined (or no param) is passed.
- *
- * {
- * type: SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
- * uid: ?number
- * }
- * @public
- */
-export const SET_PENDING_TRANSCRIBING_NOTIFICATION_UID
- = 'SET_PENDING_TRANSCRIBING_NOTIFICATION_UID';
diff --git a/react/features/transcribing/actions.ts b/react/features/transcribing/actions.ts
index db4e8828e6..965157ca85 100644
--- a/react/features/transcribing/actions.ts
+++ b/react/features/transcribing/actions.ts
@@ -1,9 +1,10 @@
-import { IStore } from '../app/types';
-import { hideNotification, showErrorNotification, showNotification } from '../notifications/actions';
-import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
+import { showErrorNotification, showNotification } from '../notifications/actions';
+import {
+ NOTIFICATION_TIMEOUT_TYPE,
+ TRANSCRIBING_NOTIFICATION_ID
+} from '../notifications/constants';
import {
- SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
_POTENTIAL_TRANSCRIBER_JOINED,
_TRANSCRIBER_JOINED,
_TRANSCRIBER_LEFT
@@ -61,54 +62,14 @@ export function potentialTranscriberJoined(participantId: string) {
* Signals that the pending transcribing notification should be shown on the
* screen.
*
- * @returns {Function}
+ * @returns {showNotification}
*/
export function showPendingTranscribingNotification() {
- return async (dispatch: IStore['dispatch']) => {
- const notification = await dispatch(showNotification({
- descriptionKey: 'transcribing.pending',
- titleKey: 'dialog.transcribing'
- }, NOTIFICATION_TIMEOUT_TYPE.LONG));
-
- 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?: string) {
- 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: IStore['dispatch'], getState: IStore['getState']) => {
- const { pendingNotificationUid } = getState()['features/transcribing'];
-
- if (pendingNotificationUid) {
- dispatch(hideNotification(pendingNotificationUid));
- dispatch(setPendingTranscribingNotificationUid());
- }
- };
+ return showNotification({
+ descriptionKey: 'transcribing.pending',
+ titleKey: 'dialog.transcribing',
+ uid: TRANSCRIBING_NOTIFICATION_ID
+ }, NOTIFICATION_TIMEOUT_TYPE.LONG);
}
/**
@@ -120,7 +81,8 @@ export function hidePendingTranscribingNotification() {
export function showStoppedTranscribingNotification() {
return showNotification({
descriptionKey: 'transcribing.off',
- titleKey: 'dialog.transcribing'
+ titleKey: 'dialog.transcribing',
+ uid: TRANSCRIBING_NOTIFICATION_ID
}, NOTIFICATION_TIMEOUT_TYPE.SHORT);
}
@@ -133,6 +95,7 @@ export function showStoppedTranscribingNotification() {
export function showTranscribingError() {
return showErrorNotification({
descriptionKey: 'transcribing.error',
- titleKey: 'transcribing.failedToStart'
+ titleKey: 'transcribing.failedToStart',
+ uid: TRANSCRIBING_NOTIFICATION_ID
}, NOTIFICATION_TIMEOUT_TYPE.LONG);
}
diff --git a/react/features/transcribing/middleware.ts b/react/features/transcribing/middleware.ts
index 61dfb04058..e57ddfed5e 100644
--- a/react/features/transcribing/middleware.ts
+++ b/react/features/transcribing/middleware.ts
@@ -1,5 +1,3 @@
-import { batch } from 'react-redux';
-
import {
HIDDEN_PARTICIPANT_JOINED,
HIDDEN_PARTICIPANT_LEFT,
@@ -14,7 +12,6 @@ import {
_TRANSCRIBER_LEFT
} from './actionTypes';
import {
- hidePendingTranscribingNotification,
potentialTranscriberJoined,
showPendingTranscribingNotification,
showStoppedTranscribingNotification,
@@ -78,10 +75,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const { participant } = action;
if (potentialTranscriberJIDs.includes(participant.id) && participant.name === TRANSCRIBER_DISPLAY_NAME) {
- batch(() => {
- dispatch(transcriberJoined(participant.id));
- dispatch(hidePendingTranscribingNotification());
- });
+ dispatch(transcriberJoined(participant.id));
}
break;
diff --git a/react/features/transcribing/reducer.ts b/react/features/transcribing/reducer.ts
index 481f842849..c219590b63 100644
--- a/react/features/transcribing/reducer.ts
+++ b/react/features/transcribing/reducer.ts
@@ -1,7 +1,6 @@
import ReducerRegistry from '../base/redux/ReducerRegistry';
import {
- SET_PENDING_TRANSCRIBING_NOTIFICATION_UID,
_POTENTIAL_TRANSCRIBER_JOINED,
_TRANSCRIBER_JOINED,
_TRANSCRIBER_LEFT
@@ -45,7 +44,6 @@ function _getInitialState() {
export interface ITranscribingState {
isTranscribing: boolean;
- pendingNotificationUid?: string;
potentialTranscriberJIDs: string[];
transcriberJID?: string | null;
}
@@ -74,11 +72,6 @@ ReducerRegistry.register<ITranscribingState>('features/transcribing',
...state,
potentialTranscriberJIDs: [ action.transcriberJID, ...state.potentialTranscriberJIDs ]
};
- case SET_PENDING_TRANSCRIBING_NOTIFICATION_UID:
- return {
- ...state,
- pendingNotificationUid: action.uid
- };
default:
return state;
}