🚸(frontend) offer a "clear effect" option

Based on user feedbacks, allow them stopping an effect
explicitly by pressing a "no effect" option.
This commit is contained in:
lebaudantoine
2025-02-21 17:54:30 +01:00
committed by aleb_the_flash
parent b962dddbf2
commit 0a63270154

View File

@@ -15,6 +15,7 @@ import { BlurOnStrong } from '@/components/icons/BlurOnStrong'
import { useTrackToggle } from '@livekit/components-react' import { useTrackToggle } from '@livekit/components-react'
import { Loader } from '@/primitives/Loader' import { Loader } from '@/primitives/Loader'
import { useSyncAfterDelay } from '@/hooks/useSyncAfterDelay' import { useSyncAfterDelay } from '@/hooks/useSyncAfterDelay'
import { RiProhibited2Line } from '@remixicon/react'
enum BlurRadius { enum BlurRadius {
NONE = 0, NONE = 0,
@@ -63,6 +64,11 @@ export const EffectsConfiguration = ({
} }
}, [videoTrack, videoTrack?.isMuted]) }, [videoTrack, videoTrack?.isMuted])
const clearEffect = async () => {
await videoTrack.stopProcessor()
onSubmit?.(undefined)
}
const toggleEffect = async ( const toggleEffect = async (
type: ProcessorType, type: ProcessorType,
options: BackgroundOptions options: BackgroundOptions
@@ -72,7 +78,7 @@ export const EffectsConfiguration = ({
/** /**
* Special case: if no video track is available, then we must pass directly the processor into the * Special case: if no video track is available, then we must pass directly the processor into the
* toggle call. Otherwise, the rest of the function below would not have a videoTrack to call * toggle call. Otherwise, the rest of the function below would not have a videoTrack to call
* setProccesor on. * setProcessor on.
* *
* We arrive in this condition when we enter the room with the camera already off. * We arrive in this condition when we enter the room with the camera already off.
*/ */
@@ -95,8 +101,7 @@ export const EffectsConfiguration = ({
try { try {
if (isSelected(type, options)) { if (isSelected(type, options)) {
// Stop processor. // Stop processor.
await videoTrack.stopProcessor() await clearEffect()
onSubmit?.(undefined)
} else if (!processor || processor.serialize().type !== type) { } else if (!processor || processor.serialize().type !== type) {
// Change processor. // Change processor.
const newProcessor = BackgroundProcessorFactory.getProcessor( const newProcessor = BackgroundProcessorFactory.getProcessor(
@@ -243,6 +248,16 @@ export const EffectsConfiguration = ({
gap: '1.25rem', gap: '1.25rem',
})} })}
> >
<ToggleButton
variant="bigSquare"
onPress={async () => {
await clearEffect()
}}
isSelected={!getProcessor()}
isDisabled={processorPendingReveal}
>
<RiProhibited2Line />
</ToggleButton>
<ToggleButton <ToggleButton
variant="bigSquare" variant="bigSquare"
aria-label={tooltipLabel(ProcessorType.BLUR, { aria-label={tooltipLabel(ProcessorType.BLUR, {