fix(calls): sidebar voice-channel join respects the voice limit
channelFull was computed only in the prescreen; a second click on the channel in the room nav joined a full channel. Extract useVoiceChannelFull, use it in both places, and refuse with a "Channel full (N/N)" toast. Fixes #30 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -80,6 +80,7 @@ import {
|
||||
} from '../../hooks/useRoomMeta';
|
||||
import { useCallMembers, useCallSession } from '../../hooks/useCall';
|
||||
import { useCallEmbed, useCallStart } from '../../hooks/useCallEmbed';
|
||||
import { useVoiceChannelFull } from '../../hooks/useVoiceChannelFull';
|
||||
import { callChatAtom } from '../../state/callEmbed';
|
||||
import { createErrorToast, toastQueueAtom } from '../../state/toast';
|
||||
import { useCallPreferencesAtom } from '../../state/hooks/callPreferences';
|
||||
@@ -691,8 +692,12 @@ function RoomNavItem_({
|
||||
const callMembers = useCallMembers(callSession);
|
||||
const startCall = useCallStart(direct);
|
||||
const callEmbed = useCallEmbed();
|
||||
// [Gitea #30] Same voice-limit check the call prescreen uses, so the sidebar
|
||||
// second-click join path can't bypass a full channel.
|
||||
const { channelFull, current: voiceCurrent, max: voiceMax } = useVoiceChannelFull(room);
|
||||
const callPref = useAtomValue(useCallPreferencesAtom());
|
||||
const autoDiscoveryInfo = useAutoDiscoveryInfo();
|
||||
const setToast = useSetAtom(toastQueueAtom);
|
||||
|
||||
const handleStartCall: MouseEventHandler<HTMLAnchorElement> = (evt) => {
|
||||
const powerLevelsEvent = getStateEvent(room, StateEvent.RoomPowerLevels);
|
||||
@@ -714,6 +719,22 @@ function RoomNavItem_({
|
||||
if (callEmbed) {
|
||||
return;
|
||||
}
|
||||
|
||||
// [Gitea #30] Refuse to start a call into a full voice channel — the
|
||||
// prescreen already blocks this, but the sidebar second-click join path
|
||||
// skipped the check entirely.
|
||||
if (channelFull) {
|
||||
evt.preventDefault();
|
||||
setToast(
|
||||
createErrorToast(
|
||||
`Channel full (${voiceCurrent}/${voiceMax})`,
|
||||
Icons.Warning,
|
||||
'Cannot join',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Start call in second click
|
||||
if (selected) {
|
||||
evt.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user