mirror of
https://github.com/element-hq/element-web.git
synced 2026-01-11 19:56:47 +00:00
Remove element_call.participant_limit config and associated code. (#31638)
* Remove `element_call.participant_limit` * fix disabledTooltip * reducer ftw * Remove unused bits * prettier
This commit is contained in:
parent
56dcb668d1
commit
13ded7db84
8 changed files with 7 additions and 45 deletions
|
|
@ -43,7 +43,6 @@
|
|||
},
|
||||
"element_call": {
|
||||
"url": "https://call.element.io",
|
||||
"participant_limit": 8,
|
||||
"brand": "Element Call"
|
||||
},
|
||||
"map_style_url": "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx"
|
||||
|
|
|
|||
|
|
@ -391,8 +391,6 @@ The VoIP and Jitsi options are:
|
|||
6. `element_call`: Optional configuration for native group calls using Element Call, with the following subkeys:
|
||||
- `use_exclusively`: A boolean specifying whether Element Call should be used exclusively as the only VoIP stack in
|
||||
the app, removing the ability to start legacy 1:1 calls or Jitsi calls. Defaults to `false`.
|
||||
- `participant_limit`: The maximum number of users who can join a call; if
|
||||
this number is exceeded, the user will not be able to join a given call.
|
||||
- `brand`: Optional name for the app. Defaults to `Element Call`. This is
|
||||
used throughout the application in various strings/locations.
|
||||
- `guest_spa_url`: Optional URL for an Element Call single-page app (SPA),
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ export interface IConfigOptions {
|
|||
element_call: {
|
||||
guest_spa_url?: string;
|
||||
use_exclusively?: boolean;
|
||||
participant_limit?: number;
|
||||
brand?: string;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ export const DEFAULTS: DeepReadonly<IConfigOptions> = {
|
|||
},
|
||||
element_call: {
|
||||
use_exclusively: false,
|
||||
participant_limit: 8,
|
||||
brand: "Element Call",
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,7 @@ import React, { type Ref, useCallback, useContext, useMemo, type JSX } from "rea
|
|||
import type { MatrixEvent, RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
import { ConnectionState, type ElementCall } from "../../../models/Call";
|
||||
import { _t } from "../../../languageHandler";
|
||||
import {
|
||||
useCall,
|
||||
useConnectionState,
|
||||
useJoinCallButtonDisabledTooltip,
|
||||
useParticipatingMembers,
|
||||
} from "../../../hooks/useCall";
|
||||
import { useCall, useConnectionState, useParticipatingMembers } from "../../../hooks/useCall";
|
||||
import defaultDispatcher from "../../../dispatcher/dispatcher";
|
||||
import type { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
|
||||
import { Action } from "../../../dispatcher/actions";
|
||||
|
|
@ -102,7 +97,6 @@ interface ActiveLoadedCallEventProps {
|
|||
const ActiveLoadedCallEvent = ({ mxEvent, call, ref }: ActiveLoadedCallEventProps): JSX.Element => {
|
||||
const connectionState = useConnectionState(call);
|
||||
const participatingMembers = useParticipatingMembers(call);
|
||||
const joinCallButtonDisabledTooltip = useJoinCallButtonDisabledTooltip(call);
|
||||
|
||||
const connect = useCallback(
|
||||
(ev: ButtonEvent) => {
|
||||
|
|
@ -146,7 +140,6 @@ const ActiveLoadedCallEvent = ({ mxEvent, call, ref }: ActiveLoadedCallEventProp
|
|||
participatingMembers={participatingMembers}
|
||||
buttonText={buttonText}
|
||||
buttonKind={buttonKind}
|
||||
buttonDisabledTooltip={joinCallButtonDisabledTooltip ?? undefined}
|
||||
onButtonClick={onButtonClick}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import type { RoomMember } from "matrix-js-sdk/src/matrix";
|
|||
import { type Call, ConnectionState, CallEvent } from "../models/Call";
|
||||
import { useTypedEventEmitterState, useEventEmitter } from "./useEventEmitter";
|
||||
import { CallStore, CallStoreEvent } from "../stores/CallStore";
|
||||
import SdkConfig, { DEFAULTS } from "../SdkConfig";
|
||||
import { _t } from "../languageHandler";
|
||||
|
||||
export const useCall = (roomId: string): Call | null => {
|
||||
const [call, setCall] = useState(() => CallStore.instance.getCall(roomId));
|
||||
|
|
@ -41,7 +39,7 @@ export const useConnectionState = (call: Call | null): ConnectionState =>
|
|||
useCallback((state) => state ?? call?.connectionState ?? ConnectionState.Disconnected, [call]),
|
||||
);
|
||||
|
||||
export const useParticipants = (call: Call | null): Map<RoomMember, Set<string>> => {
|
||||
const useParticipants = (call: Call | null): Map<RoomMember, Set<string>> => {
|
||||
return useTypedEventEmitterState(
|
||||
call ?? undefined,
|
||||
CallEvent.Participants,
|
||||
|
|
@ -53,9 +51,7 @@ export const useParticipantCount = (call: Call | null): number => {
|
|||
const participants = useParticipants(call);
|
||||
|
||||
return useMemo(() => {
|
||||
let count = 0;
|
||||
for (const devices of participants.values()) count += devices.size;
|
||||
return count;
|
||||
return [...participants.values()].reduce<number>((count, set) => count + set.size, 0);
|
||||
}, [participants]);
|
||||
};
|
||||
|
||||
|
|
@ -71,15 +67,3 @@ export const useParticipatingMembers = (call: Call): RoomMember[] => {
|
|||
return members;
|
||||
}, [participants]);
|
||||
};
|
||||
|
||||
export const useFull = (call: Call | null): boolean => {
|
||||
return (
|
||||
useParticipantCount(call) >=
|
||||
(SdkConfig.get("element_call").participant_limit ?? DEFAULTS.element_call.participant_limit!)
|
||||
);
|
||||
};
|
||||
|
||||
export const useJoinCallButtonDisabledTooltip = (call: Call | null): string | null => {
|
||||
const isFull = useFull(call);
|
||||
return isFull ? _t("voip|join_button_tooltip_call_full") : null;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4045,7 +4045,6 @@
|
|||
"hide_sidebar_button": "Hide sidebar",
|
||||
"input_devices": "Input devices",
|
||||
"jitsi_call": "Jitsi Conference",
|
||||
"join_button_tooltip_call_full": "Sorry — this call is currently full",
|
||||
"legacy_call": "Legacy Call",
|
||||
"maximise": "Fill screen",
|
||||
"maximise_call": "Maximise call",
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import { type ViewRoomPayload } from "../dispatcher/payloads/ViewRoomPayload";
|
|||
import { Action } from "../dispatcher/actions";
|
||||
import ToastStore from "../stores/ToastStore";
|
||||
import { LiveContentSummary, LiveContentType } from "../components/views/rooms/LiveContentSummary";
|
||||
import { useCall, useJoinCallButtonDisabledTooltip, useParticipantCount } from "../hooks/useCall";
|
||||
import { useCall, useParticipantCount } from "../hooks/useCall";
|
||||
import AccessibleButton, { type ButtonEvent } from "../components/views/elements/AccessibleButton";
|
||||
import { useDispatcher } from "../hooks/useDispatcher";
|
||||
import { type ActionPayload } from "../dispatcher/payloads";
|
||||
|
|
@ -70,22 +70,13 @@ interface JoinCallButtonWithCallProps {
|
|||
isRinging: boolean;
|
||||
}
|
||||
|
||||
function JoinCallButtonWithCall({
|
||||
onClick,
|
||||
call,
|
||||
disabledTooltip,
|
||||
isRinging,
|
||||
}: JoinCallButtonWithCallProps): JSX.Element {
|
||||
let disTooltip = disabledTooltip;
|
||||
const disabledBecauseFullTooltip = useJoinCallButtonDisabledTooltip(call);
|
||||
disTooltip = disabledTooltip ?? disabledBecauseFullTooltip ?? undefined;
|
||||
|
||||
function JoinCallButtonWithCall({ onClick, disabledTooltip, isRinging }: JoinCallButtonWithCallProps): JSX.Element {
|
||||
return (
|
||||
<Tooltip description={disTooltip ?? _t("voip|video_call")}>
|
||||
<Tooltip description={disabledTooltip ?? _t("voip|video_call")}>
|
||||
<Button
|
||||
className="mx_IncomingCallToast_actionButton"
|
||||
onClick={onClick}
|
||||
disabled={disTooltip != undefined}
|
||||
disabled={disabledTooltip != undefined}
|
||||
kind="primary"
|
||||
Icon={CheckIcon}
|
||||
size="sm"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue