Spaces:
Running
Running
Update src/App.tsx
Browse files- src/App.tsx +5 -5
src/App.tsx
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
// src/App.tsx
|
2 |
-
|
3 |
/**
|
4 |
Copyright 2024 Google LLC
|
5 |
... (لایسنس) ...
|
@@ -59,13 +58,14 @@ const AppCore: React.FC<{
|
|
59 |
const notificationButtonRef = useRef<HTMLButtonElement>(null);
|
60 |
const notificationPopoverRef = useRef<HTMLDivElement>(null);
|
61 |
|
62 |
-
const { connected, disconnect } = useLiveAPIContext();
|
63 |
|
|
|
64 |
useEffect(() => {
|
65 |
if (!isMicActive && !isCamActive && connected) {
|
66 |
-
|
67 |
}
|
68 |
-
}, [isMicActive, isCamActive, connected,
|
69 |
|
70 |
useEffect(() => {
|
71 |
const handleClickOutside = (event: MouseEvent) => {
|
@@ -111,7 +111,7 @@ const AppCore: React.FC<{
|
|
111 |
<ControlTray
|
112 |
videoRef={videoRef}
|
113 |
supportsVideo={true}
|
114 |
-
onVideoStreamChange={(stream) => { if(videoRef.current && stream) videoRef.current.srcObject = stream; else if(videoRef.current) videoRef.current.srcObject = null; }}
|
115 |
isAppMicActive={isMicActive}
|
116 |
onAppMicToggle={setIsMicActive}
|
117 |
isAppCamActive={isCamActive}
|
|
|
1 |
// src/App.tsx
|
|
|
2 |
/**
|
3 |
Copyright 2024 Google LLC
|
4 |
... (لایسنس) ...
|
|
|
58 |
const notificationButtonRef = useRef<HTMLButtonElement>(null);
|
59 |
const notificationPopoverRef = useRef<HTMLDivElement>(null);
|
60 |
|
61 |
+
const { connected, disconnect: liveApiDisconnect } = useLiveAPIContext(); // disconnect به liveApiDisconnect تغییر نام یافت
|
62 |
|
63 |
+
// این useEffect مسئول قطع اتصال است اگر هیچکدام از میکروفون یا دوربین فعال نباشند
|
64 |
useEffect(() => {
|
65 |
if (!isMicActive && !isCamActive && connected) {
|
66 |
+
liveApiDisconnect(); // استفاده از نام جدید
|
67 |
}
|
68 |
+
}, [isMicActive, isCamActive, connected, liveApiDisconnect]);
|
69 |
|
70 |
useEffect(() => {
|
71 |
const handleClickOutside = (event: MouseEvent) => {
|
|
|
111 |
<ControlTray
|
112 |
videoRef={videoRef}
|
113 |
supportsVideo={true}
|
114 |
+
onVideoStreamChange={(stream) => { if(videoRef.current && stream) videoRef.current.srcObject = stream; else if(videoRef.current) videoRef.current.srcObject = null; }}
|
115 |
isAppMicActive={isMicActive}
|
116 |
onAppMicToggle={setIsMicActive}
|
117 |
isAppCamActive={isCamActive}
|