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(toolbox): Fix re-rendering of toolbar on every state change.

damencho39c9c248105f
diff --git a/react/features/toolbox/components/web/Toolbox.tsx b/react/features/toolbox/components/web/Toolbox.tsx
index 84fa283cc2..ad34a54f64 100644
--- a/react/features/toolbox/components/web/Toolbox.tsx
+++ b/react/features/toolbox/components/web/Toolbox.tsx
@@ -8,6 +8,7 @@ import { isMobileBrowser } from '../../../base/environment/utils';
import { getLocalParticipant, isLocalParticipantModerator } from '../../../base/participants/functions';
import ContextMenu from '../../../base/ui/components/web/ContextMenu';
import { isReactionsButtonEnabled, shouldDisplayReactionsButtons } from '../../../reactions/functions.web';
+import { isTranscribing } from '../../../transcribing/functions';
import {
setHangupMenuVisible,
setOverflowMenuVisible,
@@ -99,8 +100,11 @@ export default function Toolbox({
const isDialogVisible = useSelector((state: IReduxState) => Boolean(state['features/base/dialog'].component));
const jwt = useSelector((state: IReduxState) => state['features/base/jwt'].jwt);
const localParticipant = useSelector(getLocalParticipant);
- const jwtDisabledButtons = useSelector((state: IReduxState) =>
- getJwtDisabledButtons(state, isModerator, jwt, localParticipant?.features));
+ const transcribing = useSelector(isTranscribing);
+
+ // Do not convert to selector, it returns new array and will cause re-rendering of toolbox on every action.
+ const jwtDisabledButtons = getJwtDisabledButtons(transcribing, isModerator, jwt, localParticipant?.features);
+
const reactionsButtonEnabled = useSelector(isReactionsButtonEnabled);
const _shouldDisplayReactionsButtons = useSelector(shouldDisplayReactionsButtons);
const toolbarVisible = useSelector(isToolboxVisible);
diff --git a/react/features/toolbox/functions.any.ts b/react/features/toolbox/functions.any.ts
index 38c8ac9d1e..dd1e985a56 100644
--- a/react/features/toolbox/functions.any.ts
+++ b/react/features/toolbox/functions.any.ts
@@ -2,7 +2,6 @@ import { IReduxState } from '../app/types';
import { isJwtFeatureEnabledStateless } from '../base/jwt/functions';
import { IGUMPendingState } from '../base/media/types';
import { IParticipantFeatures } from '../base/participants/types';
-import { isTranscribing } from '../transcribing/functions';
/**
* Indicates if the audio mute button is disabled or not.
@@ -19,15 +18,16 @@ export function isAudioMuteButtonDisabled(state: IReduxState) {
/**
* Returns the buttons corresponding to features disabled through jwt.
+ * This function is stateless as it returns a new array and may cause re-rendering.
*
- * @param {IReduxState} state - The state from the Redux store.
+ * @param {boolean} isTranscribing - Whether there is currently a transcriber in the meeting.
* @param {boolean} isModerator - Whether local participant is moderator.
* @param {string | undefined} jwt - The jwt token.
* @param {ILocalParticipant} localParticipantFeatures - The features of the local participant.
* @returns {string[]} - The disabled by jwt buttons array.
*/
export function getJwtDisabledButtons(
- state: IReduxState,
+ isTranscribing: boolean,
isModerator: boolean,
jwt: string | undefined,
localParticipantFeatures?: IParticipantFeatures) {
@@ -43,7 +43,7 @@ export function getJwtDisabledButtons(
acc.push('livestreaming');
}
- if (!isTranscribing(state) && !isJwtFeatureEnabledStateless({
+ if (!isTranscribing && !isJwtFeatureEnabledStateless({
jwt,
localParticipantFeatures,
feature: 'transcription',