Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(notifications) reset same type notification timeout
Tudor D. Popb9f344837996
diff --git a/react/features/base/participants/middleware.js b/react/features/base/participants/middleware.jsindex 4f01ce3e9f..113958598b 100644--- a/react/features/base/participants/middleware.js+++ b/react/features/base/participants/middleware.js@@ -603,7 +603,6 @@ function _raiseHandUpdated({ dispatch, getState }, conference, participantId, netitleKey: 'notify.somebody',title: notificationTitle,descriptionKey: 'notify.raisedHand',- raiseHandNotification: true,concatText: true,uid: RAISE_HAND_NOTIFICATION_ID,...actiondiff --git a/react/features/notifications/actionTypes.js b/react/features/notifications/actionTypes.jsindex f3429e0de9..88ee14af58 100644--- a/react/features/notifications/actionTypes.js+++ b/react/features/notifications/actionTypes.js@@ -45,13 +45,3 @@ export const SHOW_NOTIFICATION = 'SHOW_NOTIFICATION';* }*/export const SET_NOTIFICATIONS_ENABLED = 'SET_NOTIFICATIONS_ENABLED';--/**- * The type of (redux) action which signals that raise hand notifications- * should be dismissed.- *- * {- * type: HIDE_RAISE_HAND_NOTIFICATIONS- * }- */-export const HIDE_RAISE_HAND_NOTIFICATIONS = 'HIDE_RAISE_HAND_NOTIFICATIONS';diff --git a/react/features/notifications/actions.js b/react/features/notifications/actions.jsindex c215a32db7..0d0ec8d26e 100644--- a/react/features/notifications/actions.js+++ b/react/features/notifications/actions.js@@ -9,7 +9,6 @@ import { getParticipantCount } from '../base/participants/functions';import {CLEAR_NOTIFICATIONS,HIDE_NOTIFICATION,- HIDE_RAISE_HAND_NOTIFICATIONS,SET_NOTIFICATIONS_ENABLED,SHOW_NOTIFICATION} from './actionTypes';@@ -71,19 +70,6 @@ export function hideNotification(uid: string) {};}-/**- * Removes the raise hand notifications.- *- * @returns {{- * type: HIDE_RAISE_HAND_NOTIFICATIONS- * }}- */-export function hideRaiseHandNotifications() {- return {- type: HIDE_RAISE_HAND_NOTIFICATIONS- };-}-/*** Stops notifications from being displayed.*diff --git a/react/features/notifications/components/native/NotificationsContainer.js b/react/features/notifications/components/native/NotificationsContainer.jsindex b9f6bded07..b696b95f1b 100644--- a/react/features/notifications/components/native/NotificationsContainer.js+++ b/react/features/notifications/components/native/NotificationsContainer.js@@ -104,7 +104,7 @@ class NotificationsContainer extends Component<Props> {if (notification !== previousNotification) {this._clearNotificationDismissTimeout();- if (notification && notification.timeout && notification.props.isDismissAllowed !== false) {+ if (notification && notification.timeout) {const {timeout,uiddiff --git a/react/features/notifications/components/web/NotificationsContainer.js b/react/features/notifications/components/web/NotificationsContainer.jsindex 65adeccfd8..a365833ff5 100644--- a/react/features/notifications/components/web/NotificationsContainer.js+++ b/react/features/notifications/components/web/NotificationsContainer.js@@ -147,24 +147,6 @@ class NotificationsContainer extends Component<Props> {};}- /**- * Sets a timeout for each notification, where applicable.- *- * @inheritdoc- */- componentDidMount() {- this._updateTimeouts();- }-- /**- * Sets a timeout for each notification, where applicable.- *- * @inheritdoc- */- componentDidUpdate() {- this._updateTimeouts();- }-/*** Implements React's {@link Component#render()}.*@@ -249,31 +231,6 @@ class NotificationsContainer extends Component<Props> {);});}-- /**- * Updates the timeouts for every notification.- *- * @returns {void}- */- _updateTimeouts() {- const { _notifications } = this.props;-- for (const notification of _notifications) {- if (notification.timeout- && notification.props.isDismissAllowed !== false- && !this._timeouts.has(notification.uid)) {- const {- timeout,- uid- } = notification;- const timerID = setTimeout(() => {- this._onDismissed(uid);- }, timeout);-- this._timeouts.set(uid, timerID);- }- }- }}/**diff --git a/react/features/notifications/middleware.js b/react/features/notifications/middleware.jsindex fcc2c11382..be5acc3f6b 100644--- a/react/features/notifications/middleware.js+++ b/react/features/notifications/middleware.js@@ -13,15 +13,65 @@ import {import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';import { PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes';+import {+ CLEAR_NOTIFICATIONS,+ HIDE_NOTIFICATION,+ SHOW_NOTIFICATION+} from './actionTypes';import {clearNotifications,- hideRaiseHandNotifications,+ hideNotification,showNotification,showParticipantJoinedNotification,showParticipantLeftNotification} from './actions';-import { NOTIFICATION_TIMEOUT_TYPE } from './constants';-import { joinLeaveNotificationsDisabled } from './functions';+import {+ NOTIFICATION_TIMEOUT_TYPE,+ RAISE_HAND_NOTIFICATION_ID+} from './constants';+import { areThereNotifications, joinLeaveNotificationsDisabled } from './functions';++/**+ * Map of timers.+ *+ * @type {Map}+ */+const timers = new Map();++/**+ * Function that creates a timeout id for specific notification.+ *+ * @param {Object} notification - Notification for which we want to create a timeout.+ * @param {Function} dispatch - The Redux dispatch function.+ * @returns {void}+ */+const createTimeoutId = (notification, dispatch) => {+ const {+ timeout,+ uid+ } = notification;++ if (timeout) {+ const timerID = setTimeout(() => {+ dispatch(hideNotification(uid));+ }, timeout);++ timers.set(uid, timerID);+ }+};++/**+ * Returns notifications state.+ *+ * @param {Object} state - Global state.+ * @returns {Array<Object>} - Notifications state.+ */+const getNotifications = state => {+ const _visible = areThereNotifications(state);+ const { notifications } = state['features/notifications'];++ return _visible ? notifications : [];+};/*** Middleware that captures actions to display notifications.@@ -30,12 +80,52 @@ import { joinLeaveNotificationsDisabled } from './functions';* @returns {Function}*/MiddlewareRegistry.register(store => next => action => {++ const { dispatch, getState } = store;+ const state = getState();+switch (action.type) {+ case CLEAR_NOTIFICATIONS: {+ if (navigator.product !== 'ReactNative') {+ const _notifications = getNotifications(state);++ for (const notification of _notifications) {+ if (timers.has(notification.uid)) {+ const timeout = timers.get(notification.uid);++ clearTimeout(timeout);+ timers.delete(notification.uid);+ }+ }+ timers.clear();+ }+ break;+ }+ case SHOW_NOTIFICATION: {+ if (navigator.product !== 'ReactNative') {+ if (timers.has(action.uid)) {+ const timer = timers.get(action.uid);++ clearTimeout(timer);+ timers.delete(action.uid);+ }++ createTimeoutId(action, dispatch);+ }+ break;+ }+ case HIDE_NOTIFICATION: {+ if (navigator.product !== 'ReactNative') {+ const timer = timers.get(action.uid);++ clearTimeout(timer);+ timers.delete(action.uid);+ }+ break;+ }case PARTICIPANT_JOINED: {const result = next(action);const { participant: p } = action;- const { dispatch, getState } = store;- const state = getState();const { conference } = state['features/base/conference'];if (conference && !p.local && !joinLeaveNotificationsDisabled() && !p.isReplacing) {@@ -48,8 +138,6 @@ MiddlewareRegistry.register(store => next => action => {}case PARTICIPANT_LEFT: {if (!joinLeaveNotificationsDisabled()) {- const { dispatch, getState } = store;- const state = getState();const participant = getParticipantById(store.getState(),action.participant.id@@ -65,7 +153,6 @@ MiddlewareRegistry.register(store => next => action => {return next(action);}case PARTICIPANT_UPDATED: {- const state = store.getState();const { disableModeratorIndicator } = state['features/base/config'];if (disableModeratorIndicator) {@@ -93,7 +180,7 @@ MiddlewareRegistry.register(store => next => action => {return next(action);}case PARTICIPANTS_PANE_OPEN: {- store.dispatch(hideRaiseHandNotifications());+ store.dispatch(hideNotification(RAISE_HAND_NOTIFICATION_ID));break;}}diff --git a/react/features/notifications/reducer.js b/react/features/notifications/reducer.jsindex 6bfd06c29a..62380ee376 100644--- a/react/features/notifications/reducer.js+++ b/react/features/notifications/reducer.js@@ -5,7 +5,6 @@ import { ReducerRegistry } from '../base/redux';import {CLEAR_NOTIFICATIONS,HIDE_NOTIFICATION,- HIDE_RAISE_HAND_NOTIFICATIONS,SET_NOTIFICATIONS_ENABLED,SHOW_NOTIFICATION} from './actionTypes';@@ -44,14 +43,6 @@ ReducerRegistry.register('features/notifications',notification => notification.uid !== action.uid)};- case HIDE_RAISE_HAND_NOTIFICATIONS:- return {- ...state,- notifications: state.notifications.filter(- notification => !notification.props.raiseHandNotification- )- };-case SET_NOTIFICATIONS_ENABLED:return {...state,diff --git a/react/features/recording/actions.any.js b/react/features/recording/actions.any.jsindex 47365c2758..921d4150f8 100644--- a/react/features/recording/actions.any.js+++ b/react/features/recording/actions.any.js@@ -96,7 +96,6 @@ export function showPendingRecordingNotification(streamType: string) {titleKey: 'dialog.recording'};const notification = await dispatch(showNotification({- isDismissAllowed: false,...dialogProps}, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));@@ -172,7 +171,6 @@ export function showStartedRecordingNotification(let dialogProps = {descriptionKey: participantName ? 'liveStreaming.onBy' : 'liveStreaming.on',descriptionArguments: { name: participantName },- isDismissAllowed: true,titleKey: 'dialog.liveStreaming'};@@ -185,7 +183,6 @@ export function showStartedRecordingNotification(customActionNameKey: undefined,descriptionKey: participantName ? 'recording.onBy' : 'recording.on',descriptionArguments: { name: participantName },- isDismissAllowed: true,titleKey: 'dialog.recording'};@@ -210,7 +207,6 @@ export function showStartedRecordingNotification(dialogProps.customActionHandler = [ () => copyText(link) ];dialogProps.titleKey = 'recording.on';dialogProps.descriptionKey = 'recording.linkGenerated';- dialogProps.isDismissAllowed = false;} catch (err) {dispatch(showErrorNotification({titleKey: 'recording.errorFetchingLink'diff --git a/react/features/transcribing/actions.js b/react/features/transcribing/actions.jsindex eb90c0bbbf..1af4aca1fd 100644--- a/react/features/transcribing/actions.js+++ b/react/features/transcribing/actions.js@@ -72,7 +72,6 @@ export function showPendingTranscribingNotification() {return async (dispatch: Function) => {const notification = await dispatch(showNotification({descriptionKey: 'transcribing.pending',- isDismissAllowed: false,titleKey: 'dialog.transcribing'}, NOTIFICATION_TIMEOUT_TYPE.LONG));