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,12 @@
/**
* The type of Redux action which sets the pending notification UID
* to use it for when hiding the notification is necessary, or unsets it when
* undefined (or no param) is passed.
*
* {
* type: SET_CURRENT_NOTIFICATION_UID,
* uid: ?number
* }
* @public
*/
export const SET_CURRENT_NOTIFICATION_UID = 'SET_CURRENT_NOTIFICATION_UID';

View File

@@ -0,0 +1,19 @@
import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes';
/**
* Sets UID of the the pending 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_CURRENT_NOTIFICATION_UID,
* uid: number
* }}
*/
export function setCurrentNotificationUid(uid?: string) {
return {
type: SET_CURRENT_NOTIFICATION_UID,
uid
};
}

View File

@@ -0,0 +1,6 @@
/**
* The identifier of the sound to be played when we got event for talking while muted.
*
* @type {string}
*/
export const TALK_WHILE_MUTED_SOUND_ID = 'TALK_WHILE_MUTED_SOUND';

View File

@@ -0,0 +1,75 @@
import { MEDIA_TYPE } from '../av-moderation/constants';
import { isForceMuted } from '../av-moderation/functions';
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 { setAudioMuted } from '../base/media/actions';
import { raiseHand } from '../base/participants/actions';
import { getLocalParticipant } from '../base/participants/functions';
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 { isAudioMuteButtonDisabled } from '../toolbox/functions.any';
import { setCurrentNotificationUid } from './actions';
import { TALK_WHILE_MUTED_SOUND_ID } from './constants';
import { TALK_WHILE_MUTED_SOUND_FILE } from './sounds';
MiddlewareRegistry.register(store => next => action => {
const result = next(action);
const { dispatch, getState } = store;
const { conference } = action;
switch (action.type) {
case APP_WILL_MOUNT:
dispatch(registerSound(TALK_WHILE_MUTED_SOUND_ID, TALK_WHILE_MUTED_SOUND_FILE));
break;
case APP_WILL_UNMOUNT:
dispatch(unregisterSound(TALK_WHILE_MUTED_SOUND_ID));
break;
case CONFERENCE_JOINED: {
conference.on(
JitsiConferenceEvents.TRACK_MUTE_CHANGED,
(track: any) => {
const { currentNotificationUid } = getState()['features/talk-while-muted'];
if (currentNotificationUid && track.isAudioTrack() && track.isLocal() && !track.isMuted()) {
dispatch(hideNotification(currentNotificationUid));
dispatch(setCurrentNotificationUid());
}
});
conference.on(
JitsiConferenceEvents.TALK_WHILE_MUTED, () => {
const state = getState();
const local = getLocalParticipant(state);
// Display the talk while muted notification only when the audio button is not disabled.
if (!isAudioMuteButtonDisabled(state)) {
const forceMuted = isForceMuted(local, MEDIA_TYPE.AUDIO, state);
const notification = dispatch(showNotification({
titleKey: 'toolbar.talkWhileMutedPopup',
customActionNameKey: [ forceMuted ? 'notify.raiseHandAction' : 'notify.unmute' ],
customActionHandler: [ () => dispatch(forceMuted ? raiseHand(true) : setAudioMuted(false)) ]
}, NOTIFICATION_TIMEOUT_TYPE.LONG));
const { soundsTalkWhileMuted } = getState()['features/base/settings'];
if (soundsTalkWhileMuted) {
dispatch(playSound(TALK_WHILE_MUTED_SOUND_ID));
}
if (notification) {
// we store the last start muted notification id that we showed,
// so we can hide it when unmuted mic is detected
dispatch(setCurrentNotificationUid(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_CURRENT_NOTIFICATION_UID } from './actionTypes';
export interface ITalkWhileMutedState {
currentNotificationUid?: string;
}
/**
* Reduces the redux actions of the feature talk while muted.
*/
ReducerRegistry.register<ITalkWhileMutedState>('features/talk-while-muted',
(state = {}, action): ITalkWhileMutedState => {
switch (action.type) {
case SET_CURRENT_NOTIFICATION_UID:
return set(state, 'currentNotificationUid', action.uid);
}
return state;
});

View File

@@ -0,0 +1,6 @@
/**
* The file used for the talk while muted sound notification.
*
* @type {string}
*/
export const TALK_WHILE_MUTED_SOUND_FILE = 'talkWhileMuted.mp3';