Skip to content

Commit 3ee3b1a

Browse files
feedback
1 parent 9cce39f commit 3ee3b1a

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

components/app/session-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { ScrollArea } from '../livekit/scroll-area/scroll-area';
1818

1919
const MotionBottom = motion.create('div');
2020

21-
const IN_DEVELOPMENT = process.env.NODE_END !== 'production';
21+
const IN_DEVELOPMENT = process.env.NODE_ENV !== 'production';
2222
const BOTTOM_VIEW_MOTION_PROPS = {
2323
variants: {
2424
visible: {

components/livekit/agent-control-bar/agent-control-bar.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import { UseInputControlsProps, useInputControls } from './hooks/use-input-contr
1313
import { usePublishPermissions } from './hooks/use-publish-permissions';
1414
import { TrackSelector } from './track-selector';
1515

16-
const NOOP = () => {};
17-
1816
export interface ControlBarControls {
1917
leave?: boolean;
2018
camera?: boolean;
@@ -37,9 +35,9 @@ export function AgentControlBar({
3735
controls,
3836
saveUserChoices = true,
3937
className,
40-
onDisconnect = NOOP,
41-
onDeviceError = NOOP,
42-
onChatOpenChange = NOOP,
38+
onDisconnect,
39+
onDeviceError,
40+
onChatOpenChange,
4341
...props
4442
}: AgentControlBarProps & HTMLAttributes<HTMLDivElement>) {
4543
const { send } = useChat();
@@ -74,7 +72,7 @@ export function AgentControlBar({
7472
const handleToggleTranscript = useCallback(
7573
(open: boolean) => {
7674
setChatOpen(open);
77-
onChatOpenChange(open);
75+
onChatOpenChange?.(open);
7876
},
7977
[onChatOpenChange, setChatOpen]
8078
);
@@ -87,7 +85,7 @@ export function AgentControlBar({
8785
}
8886

8987
setIsDisconnecting(false);
90-
onDisconnect();
88+
onDisconnect?.();
9189
}, [room, onDisconnect]);
9290

9391
const visibleControls = {

components/livekit/agent-control-bar/hooks/use-input-controls.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {
77
useTrackToggle,
88
} from '@livekit/components-react';
99

10-
const NOOP = () => {};
11-
1210
export interface UseInputControlsProps {
1311
saveUserChoices?: boolean;
1412
onDisconnect?: () => void;
@@ -28,23 +26,23 @@ export interface UseInputControlsReturn {
2826

2927
export function useInputControls({
3028
saveUserChoices = true,
31-
onDeviceError = NOOP,
29+
onDeviceError,
3230
}: UseInputControlsProps = {}): UseInputControlsReturn {
3331
const { microphoneTrack, localParticipant } = useLocalParticipant();
3432

3533
const microphoneToggle = useTrackToggle({
3634
source: Track.Source.Microphone,
37-
onDeviceError: (error) => onDeviceError({ source: Track.Source.Microphone, error }),
35+
onDeviceError: (error) => onDeviceError?.({ source: Track.Source.Microphone, error }),
3836
});
3937

4038
const cameraToggle = useTrackToggle({
4139
source: Track.Source.Camera,
42-
onDeviceError: (error) => onDeviceError({ source: Track.Source.Camera, error }),
40+
onDeviceError: (error) => onDeviceError?.({ source: Track.Source.Camera, error }),
4341
});
4442

4543
const screenShareToggle = useTrackToggle({
4644
source: Track.Source.ScreenShare,
47-
onDeviceError: (error) => onDeviceError({ source: Track.Source.ScreenShare, error }),
45+
onDeviceError: (error) => onDeviceError?.({ source: Track.Source.ScreenShare, error }),
4846
});
4947

5048
const micTrackRef = useMemo(() => {
@@ -107,12 +105,12 @@ export function useInputControls({
107105
[cameraToggle, screenShareToggle]
108106
);
109107
const handleMicrophoneDeviceSelectError = useCallback(
110-
(error: Error) => onDeviceError({ source: Track.Source.Microphone, error }),
108+
(error: Error) => onDeviceError?.({ source: Track.Source.Microphone, error }),
111109
[onDeviceError]
112110
);
113111

114112
const handleCameraDeviceSelectError = useCallback(
115-
(error: Error) => onDeviceError({ source: Track.Source.Camera, error }),
113+
(error: Error) => onDeviceError?.({ source: Track.Source.Camera, error }),
116114
[onDeviceError]
117115
);
118116

components/livekit/agent-control-bar/track-device-select.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import {
1313
} from '@/components/livekit/select';
1414
import { cn } from '@/lib/utils';
1515

16-
const NOOP = () => {};
17-
1816
type DeviceSelectProps = React.ComponentProps<typeof SelectTrigger> & {
1917
kind: MediaDeviceKind;
2018
variant?: 'default' | 'small';
@@ -45,9 +43,9 @@ export function TrackDeviceSelect({
4543
track,
4644
size = 'default',
4745
requestPermissions = false,
48-
onMediaDeviceError = NOOP,
49-
onDeviceListChange = NOOP,
50-
onActiveDeviceChange = NOOP,
46+
onMediaDeviceError,
47+
onDeviceListChange,
48+
onActiveDeviceChange,
5149
...props
5250
}: DeviceSelectProps) {
5351
const room = useMaybeRoomContext();
@@ -62,7 +60,7 @@ export function TrackDeviceSelect({
6260
});
6361

6462
useEffect(() => {
65-
onDeviceListChange(devices);
63+
onDeviceListChange?.(devices);
6664
}, [devices, onDeviceListChange]);
6765

6866
// When the select opens, ensure that media devices are re-requested in case when they were last
@@ -75,7 +73,7 @@ export function TrackDeviceSelect({
7573

7674
const handleActiveDeviceChange = (deviceId: string) => {
7775
setActiveMediaDevice(deviceId);
78-
onActiveDeviceChange(deviceId);
76+
onActiveDeviceChange?.(deviceId);
7977
};
8078

8179
const filteredDevices = useMemo(() => devices.filter((d) => d.deviceId !== ''), [devices]);

components/livekit/scroll-area/hooks/useAutoScroll.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect } from 'react';
22

3-
const AUTO_SCROLL_THRESHOLD = 50;
3+
const AUTO_SCROLL_THRESHOLD_PX = 50;
44

55
export function useAutoScroll(scrollContentContainer?: Element | null) {
66
useEffect(() => {
@@ -12,7 +12,7 @@ export function useAutoScroll(scrollContentContainer?: Element | null) {
1212
scrollContentContainer.clientHeight -
1313
scrollContentContainer.scrollTop;
1414

15-
if (distanceFromBottom < AUTO_SCROLL_THRESHOLD) {
15+
if (distanceFromBottom < AUTO_SCROLL_THRESHOLD_PX) {
1616
scrollContentContainer.scrollTop = scrollContentContainer.scrollHeight;
1717
}
1818
}

0 commit comments

Comments
 (0)