feat(e2ee): adds sounds for e2ee enabling/disabling

This commit is contained in:
tmoldovan8x8 2021-03-30 12:59:32 +03:00 committed by GitHub
parent b826fc1d5a
commit b1d7debfb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// @flow
/**
* The identifier of the sound to be played when e2ee is disabled.
*
* @type {string}
*/
export const E2EE_OFF_SOUND_ID = 'E2EE_OFF_SOUND';
/**
* The identifier of the sound to be played when e2ee is enabled.
*
* @type {string}
*/
export const E2EE_ON_SOUND_ID = 'E2EE_ON_SOUND';

View File

@ -1,12 +1,16 @@
// @flow // @flow
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
import { getCurrentConference } from '../base/conference'; import { getCurrentConference } from '../base/conference';
import { getLocalParticipant, participantUpdated } from '../base/participants'; import { getLocalParticipant, participantUpdated } from '../base/participants';
import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux'; import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
import { playSound, registerSound, unregisterSound } from '../base/sounds';
import { TOGGLE_E2EE } from './actionTypes'; import { TOGGLE_E2EE } from './actionTypes';
import { toggleE2EE } from './actions'; import { toggleE2EE } from './actions';
import { E2EE_OFF_SOUND_ID, E2EE_ON_SOUND_ID } from './constants';
import logger from './logger'; import logger from './logger';
import { E2EE_OFF_SOUND_FILE, E2EE_ON_SOUND_FILE } from './sounds';
/** /**
* Middleware that captures actions related to E2EE. * Middleware that captures actions related to E2EE.
@ -16,6 +20,21 @@ import logger from './logger';
*/ */
MiddlewareRegistry.register(({ dispatch, getState }) => next => action => { MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
switch (action.type) { switch (action.type) {
case APP_WILL_MOUNT:
dispatch(registerSound(
E2EE_OFF_SOUND_ID,
E2EE_OFF_SOUND_FILE));
dispatch(registerSound(
E2EE_ON_SOUND_ID,
E2EE_ON_SOUND_FILE));
break;
case APP_WILL_UNMOUNT:
dispatch(unregisterSound(E2EE_OFF_SOUND_ID));
dispatch(unregisterSound(E2EE_ON_SOUND_ID));
break;
case TOGGLE_E2EE: { case TOGGLE_E2EE: {
const conference = getCurrentConference(getState); const conference = getCurrentConference(getState);
@ -31,6 +50,10 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
id: participant.id, id: participant.id,
local: true local: true
})); }));
const soundID = action.enabled ? E2EE_ON_SOUND_ID : E2EE_OFF_SOUND_ID;
dispatch(playSound(soundID));
} }
break; break;

View File

@ -0,0 +1,15 @@
// @flow
/**
* The name of the bundled audio file which will be played when e2ee is disabled.
*
* @type {string}
*/
export const E2EE_OFF_SOUND_FILE = 'e2eeOff.mp3';
/**
* The name of the bundled audio file which will be played when e2ee is enabled.
*
* @type {string}
*/
export const E2EE_ON_SOUND_FILE = 'e2eeOn.mp3';

BIN
sounds/e2eeOff.mp3 Normal file

Binary file not shown.

BIN
sounds/e2eeOn.mp3 Normal file

Binary file not shown.