feat(calls): toast when a room admin turns off screen sharing / camera mid-call (#223)
Re-measured the revoke on the current stack (guard fix + fork lotus.4): the SFU drops the sharer's tracks and EC's own button, the captured tracks and our control bar all follow within ~2-4 s — the 30 s lag is gone. What remained was that the button simply vanished with no explanation, so a call-lifetime hook now toasts 'Screen sharing was turned off by a room admin.' (or the camera variant) when a track ends while the room policy forbids it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -46,6 +46,7 @@ import { useMatrixClient } from '../hooks/useMatrixClient';
|
||||
import { previewRingtone, startRingtone, unlockRingtoneAudio } from '../utils/ringtones';
|
||||
import { useCallMembersChange, useCallSession } from '../hooks/useCall';
|
||||
import { useCallJoinLeaveSounds } from '../hooks/useCallJoinLeaveSounds';
|
||||
import { useCallPolicyRevokedToast } from '../hooks/useCallPolicyRevokedToast';
|
||||
import { useCallHotkeys } from '../hooks/useCallHotkeys';
|
||||
import { useAfkAutoMute } from '../hooks/useAfkAutoMute';
|
||||
import { useCallQuality } from '../hooks/useCallQuality';
|
||||
@@ -685,6 +686,7 @@ function CallUtils({ embed, joined }: { embed: CallEmbed; joined: boolean }) {
|
||||
useCallHotkeys(embed, joined);
|
||||
useAfkAutoMute(joined ? embed : undefined);
|
||||
useCallJoinLeaveSounds(embed);
|
||||
useCallPolicyRevokedToast(embed, joined);
|
||||
useCallThemeSync(embed);
|
||||
useCallQuality(embed);
|
||||
useCallHangupEvent(
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { CallEmbed, useCallControlState } from '../plugins/call';
|
||||
import { useRoomCallPolicy } from './useRoomCallPolicy';
|
||||
import { toastQueueAtom } from '../state/toast';
|
||||
|
||||
/**
|
||||
* [Gitea #223] When a room admin turns Allow Screen Sharing / Allow Camera
|
||||
* off mid-call, the voice-limit-guard revokes the publish permission and the
|
||||
* SFU drops our track within seconds — the button just vanishes with no
|
||||
* explanation. Tell the user why: a track that went away while the room policy
|
||||
* forbids it was not their doing.
|
||||
*/
|
||||
export function useCallPolicyRevokedToast(embed: CallEmbed, joined: boolean): void {
|
||||
const { screenshare, video } = useCallControlState(embed.control);
|
||||
const { allowScreenshare, allowCamera } = useRoomCallPolicy(embed.room);
|
||||
const setToast = useSetAtom(toastQueueAtom);
|
||||
const prev = useRef({ screenshare, video });
|
||||
|
||||
useEffect(() => {
|
||||
const was = prev.current;
|
||||
prev.current = { screenshare, video };
|
||||
if (!joined) return;
|
||||
const notify = (body: string) =>
|
||||
setToast({
|
||||
id: `call-policy-${Date.now()}`,
|
||||
displayName: 'Lotus Chat',
|
||||
body,
|
||||
roomName: embed.room.name ?? 'Voice call',
|
||||
roomId: embed.roomId,
|
||||
});
|
||||
if (was.screenshare && !screenshare && !allowScreenshare) {
|
||||
notify('Screen sharing was turned off by a room admin.');
|
||||
}
|
||||
if (was.video && !video && !allowCamera) {
|
||||
notify('Your camera was turned off by a room admin.');
|
||||
}
|
||||
}, [screenshare, video, allowScreenshare, allowCamera, joined, setToast, embed]);
|
||||
}
|
||||
Reference in New Issue
Block a user