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(notifications) Create web middleware (#10568)

Robert Pintilii0e9b40c41077
diff --git a/react/features/app/middlewares.web.js b/react/features/app/middlewares.web.js
index ed5d44ab20..acb9d3ea1b 100644
--- a/react/features/app/middlewares.web.js
+++ b/react/features/app/middlewares.web.js
@@ -8,6 +8,7 @@ import '../external-api/middleware';
import '../keyboard-shortcuts/middleware';
import '../local-recording/middleware';
import '../no-audio-signal/middleware';
+import '../notifications/middleware';
import '../noise-detection/middleware';
import '../old-client-notification/middleware';
import '../power-monitor/middleware';
diff --git a/react/features/notifications/middleware.js b/react/features/notifications/middleware.any.js
similarity index 82%
rename from react/features/notifications/middleware.js
rename to react/features/notifications/middleware.any.js
index b8003d4d20..fcc2c11382 100644
--- a/react/features/notifications/middleware.js
+++ b/react/features/notifications/middleware.any.js
@@ -1,6 +1,6 @@
/* @flow */
-import { CONFERENCE_JOINED, getCurrentConference } from '../base/conference';
+import { getCurrentConference } from '../base/conference';
import {
PARTICIPANT_JOINED,
PARTICIPANT_LEFT,
@@ -12,7 +12,6 @@ import {
} from '../base/participants';
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
import { PARTICIPANTS_PANE_OPEN } from '../participants-pane/actionTypes';
-import { openSettingsDialog, SETTINGS_TABS } from '../settings';
import {
clearNotifications,
@@ -32,21 +31,6 @@ import { joinLeaveNotificationsDisabled } from './functions';
*/
MiddlewareRegistry.register(store => next => action => {
switch (action.type) {
- case CONFERENCE_JOINED: {
- const { dispatch, getState } = store;
- const { disableSelfView } = getState()['features/base/settings'];
-
- if (disableSelfView) {
- dispatch(showNotification({
- titleKey: 'notify.selfViewTitle',
- customActionNameKey: [ 'settings.title' ],
- customActionHandler: [ () =>
- dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE))
- ]
- }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
- }
- break;
- }
case PARTICIPANT_JOINED: {
const result = next(action);
const { participant: p } = action;
diff --git a/react/features/notifications/middleware.native.js b/react/features/notifications/middleware.native.js
new file mode 100644
index 0000000000..fefd329e8a
--- /dev/null
+++ b/react/features/notifications/middleware.native.js
@@ -0,0 +1 @@
+import './middleware.any';
diff --git a/react/features/notifications/middleware.web.js b/react/features/notifications/middleware.web.js
new file mode 100644
index 0000000000..7edff0e2da
--- /dev/null
+++ b/react/features/notifications/middleware.web.js
@@ -0,0 +1,40 @@
+/* @flow */
+
+import { CONFERENCE_JOINED } from '../base/conference';
+import { MiddlewareRegistry } from '../base/redux';
+import { openSettingsDialog, SETTINGS_TABS } from '../settings';
+
+import {
+ showNotification
+} from './actions';
+import { NOTIFICATION_TIMEOUT_TYPE } from './constants';
+
+import './middleware.any';
+
+/**
+ * Middleware that captures actions to display notifications.
+ *
+ * @param {Store} store - The redux store.
+ * @returns {Function}
+ */
+MiddlewareRegistry.register(store => next => action => {
+ switch (action.type) {
+ case CONFERENCE_JOINED: {
+ const { dispatch, getState } = store;
+ const { disableSelfView } = getState()['features/base/settings'];
+
+ if (disableSelfView) {
+ dispatch(showNotification({
+ titleKey: 'notify.selfViewTitle',
+ customActionNameKey: [ 'settings.title' ],
+ customActionHandler: [ () =>
+ dispatch(openSettingsDialog(SETTINGS_TABS.PROFILE))
+ ]
+ }, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
+ }
+ break;
+ }
+ }
+
+ return next(action);
+});