init
Some checks failed
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
2025-09-02 14:49:16 +08:00
commit 38ba663466
2885 changed files with 391107 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
/**
* The type of Redux action which sets the pending notification UID
* to use it when hiding the notification is necessary, or unset it when
* undefined (or no param) is passed.
*
* {
* type: SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID
* uid: ?number
* }
*/
export const SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID = 'SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID';

View File

@@ -0,0 +1,19 @@
import { SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID } from './actionTypes';
/**
* Sets UID of the the pending notification to use it when hiding
* the notification is necessary, or unset it when undefined (or no param) is
* passed.
*
* @param {?number} uid - The UID of the notification.
* @returns {{
* type: SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID,
* uid: number
* }}
*/
export function setNoisyAudioInputNotificationUid(uid?: string) {
return {
type: SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID,
uid
};
}

View File

@@ -0,0 +1,6 @@
/**
* The identifier of the sound to be played when we display a you are noisy notification.
*
* @type {string}
*/
export const NOISY_AUDIO_INPUT_SOUND_ID = 'NOISY_AUDIO_INPUT_SOUND';

View File

@@ -0,0 +1,57 @@
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app/actionTypes';
import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { playSound, registerSound, unregisterSound } from '../base/sounds/actions';
import { hideNotification, showNotification } from '../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
import { setNoisyAudioInputNotificationUid } from './actions';
import { NOISY_AUDIO_INPUT_SOUND_ID } from './constants';
import { NOISY_AUDIO_INPUT_SOUND_FILE } from './sounds';
MiddlewareRegistry.register(store => next => action => {
const result = next(action);
switch (action.type) {
case APP_WILL_MOUNT:
store.dispatch(registerSound(NOISY_AUDIO_INPUT_SOUND_ID, NOISY_AUDIO_INPUT_SOUND_FILE));
break;
case APP_WILL_UNMOUNT:
store.dispatch(unregisterSound(NOISY_AUDIO_INPUT_SOUND_ID));
break;
case CONFERENCE_JOINED: {
const { dispatch, getState } = store;
const { conference } = action;
conference.on(
JitsiConferenceEvents.TRACK_MUTE_CHANGED,
(track: any) => {
const { noisyAudioInputNotificationUid } = getState()['features/noise-detection'];
// Hide the notification in case the user mutes the microphone
if (noisyAudioInputNotificationUid && track.isAudioTrack() && track.isLocal() && track.isMuted()) {
dispatch(hideNotification(noisyAudioInputNotificationUid));
dispatch(setNoisyAudioInputNotificationUid());
}
});
conference.on(
JitsiConferenceEvents.NOISY_MIC, () => {
const notification = dispatch(showNotification({
titleKey: 'toolbar.noisyAudioInputTitle',
descriptionKey: 'toolbar.noisyAudioInputDesc'
}, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
dispatch(playSound(NOISY_AUDIO_INPUT_SOUND_ID));
if (notification) {
// we store the last notification id so we can hide it if the mic is muted
dispatch(setNoisyAudioInputNotificationUid(notification.uid));
}
});
break;
}
}
return result;
});

View File

@@ -0,0 +1,21 @@
import ReducerRegistry from '../base/redux/ReducerRegistry';
import { set } from '../base/redux/functions';
import { SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID } from './actionTypes';
export interface INoiseDetectionState {
noisyAudioInputNotificationUid?: string;
}
/**
* Reduces the redux actions of noise detection feature.
*/
ReducerRegistry.register<INoiseDetectionState>('features/noise-detection',
(state = {}, action): INoiseDetectionState => {
switch (action.type) {
case SET_NOISY_AUDIO_INPUT_NOTIFICATION_UID:
return set(state, 'noisyAudioInputNotificationUid', action.uid);
}
return state;
});

View File

@@ -0,0 +1,6 @@
/**
* The file used for the noisy audio input notification.
*
* @type {string}
*/
export const NOISY_AUDIO_INPUT_SOUND_FILE = 'noisyAudioInput.mp3';