Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 701a368

Browse files
chore(deps): update dependency @types/react to v18 (#8)
* chore(deps): update dependency @types/react to v18 * chore: yarn upgrade * fix: type-check Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: mikan3rd <[email protected]>
1 parent 72c760d commit 701a368

File tree

15 files changed

+329
-310
lines changed

15 files changed

+329
-310
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@types/crypto-js": "4.1.1",
3838
"@types/jsrsasign": "10.5.1",
3939
"@types/lodash": "4.14.182",
40-
"@types/react": "17.0.47",
40+
"@types/react": "18.0.15",
4141
"@types/react-dom": "18.0.6",
4242
"@types/react-router-dom": "5.3.3",
4343
"@typescript-eslint/eslint-plugin": "5.30.6",

src/App.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { useCallback, useContext, useEffect, useMemo, useReducer, useState } from "react";
22

3-
import ZoomVideo, { ConnectionState } from "@zoom/videosdk";
3+
import ZoomVideo, {
4+
ConnectionState,
5+
event_connection_change,
6+
event_dial_out_change,
7+
event_media_sdk_change,
8+
} from "@zoom/videosdk";
49
import { Modal, message } from "antd";
510
import { produce } from "immer";
611
import { Route, BrowserRouter as Router, Switch } from "react-router-dom";
@@ -139,7 +144,7 @@ function App(props: AppProps) {
139144
};
140145
}, [signature, zmClient, topic, name, password, webEndpoint, galleryViewWithoutSAB]);
141146
const onConnectionChange = useCallback(
142-
(payload) => {
147+
(payload: Parameters<typeof event_connection_change>[0]) => {
143148
if (payload.state === ConnectionState.Reconnecting) {
144149
setIsLoading(true);
145150
setIsFailover(true);
@@ -153,7 +158,7 @@ function App(props: AppProps) {
153158
if (isFailover) {
154159
setIsLoading(false);
155160
}
156-
} else if (payload.state === ConnectionState.Closed) {
161+
} else {
157162
setStatus("closed");
158163
dispatch({ type: "reset-media" });
159164
if (payload.reason === "ended by host") {
@@ -166,19 +171,15 @@ function App(props: AppProps) {
166171
},
167172
[isFailover],
168173
);
169-
const onMediaSDKChange = useCallback((payload) => {
174+
const onMediaSDKChange = useCallback((payload: Parameters<typeof event_media_sdk_change>[0]) => {
170175
const { action, type, result } = payload;
171176
dispatch({ type: `${type}-${action}`, payload: result === "success" });
172177
}, []);
173178

174-
const onDialoutChange = useCallback((payload) => {
179+
const onDialoutChange = useCallback((payload: Parameters<typeof event_dial_out_change>[0]) => {
175180
console.info("onDialoutChange", payload);
176181
}, []);
177182

178-
const onAudioMerged = useCallback((payload) => {
179-
console.info("onAudioMerged", payload);
180-
}, []);
181-
182183
const onLeaveOrJoinSession = useCallback(async () => {
183184
if (status === "closed") {
184185
setIsLoading(true);
@@ -193,14 +194,13 @@ function App(props: AppProps) {
193194
zmClient.on("connection-change", onConnectionChange);
194195
zmClient.on("media-sdk-change", onMediaSDKChange);
195196
zmClient.on("dialout-state-change", onDialoutChange);
196-
zmClient.on("merged-audio", onAudioMerged);
197+
197198
return () => {
198199
zmClient.off("connection-change", onConnectionChange);
199200
zmClient.off("media-sdk-change", onMediaSDKChange);
200201
zmClient.off("dialout-state-change", onDialoutChange);
201-
zmClient.off("merged-audio", onAudioMerged);
202202
};
203-
}, [zmClient, onConnectionChange, onMediaSDKChange, onDialoutChange, onAudioMerged]);
203+
}, [zmClient, onConnectionChange, onMediaSDKChange, onDialoutChange]);
204204
return (
205205
<div className="App">
206206
{loading && <LoadingLayer content={loadingText} />}

src/feature/chat/chat.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useCallback, useContext, useEffect, useRef, useState } from "react";
22

3-
import { ChatPrivilege } from "@zoom/videosdk";
3+
import { ChatPrivilege, event_chat_privilege_change } from "@zoom/videosdk";
44
import { Input } from "antd";
55
import { produce } from "immer";
66

@@ -60,7 +60,7 @@ const ChatContainer = () => {
6060
[chatWrapRef],
6161
);
6262
const onChatPrivilegeChange = useCallback(
63-
(payload) => {
63+
(payload: Parameters<typeof event_chat_privilege_change>[0]) => {
6464
setChatPrivilege(payload.chatPrivilege);
6565
if (chatClient !== null) {
6666
setChatReceivers(chatClient.getReceivers());
@@ -103,7 +103,7 @@ const ChatContainer = () => {
103103
}
104104
}, [chatReceivers, chatUser]);
105105
const setChatUserId = useCallback(
106-
(userId) => {
106+
(userId: number) => {
107107
const user = chatReceivers.find((u) => u.userId === userId);
108108
if (user !== undefined) {
109109
setChatUser(user);

src/feature/chat/component/chat-receiver.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const ChatReceiverContainer = (props: ChatReceiverProps) => {
4848
</MenuItem>
4949
));
5050
const onMenuItemClick = useCallback(
51-
({ key }) => {
51+
({ key }: { key: string }) => {
5252
const userId = Number(key);
5353
if (userId !== selectedChatUser?.userId) {
5454
setChatUser(userId);
@@ -57,7 +57,7 @@ const ChatReceiverContainer = (props: ChatReceiverProps) => {
5757
[selectedChatUser, setChatUser],
5858
);
5959
const onMenuItemPrivilegeClick = useCallback(
60-
({ key }) => {
60+
({ key }: { key: string }) => {
6161
const privilege = Number(key);
6262
if (chatPrivilege !== privilege) {
6363
chatClient?.setPrivilege(privilege);

src/feature/command/command.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const CommandContainer = () => {
119119
}
120120
}, [commandReceivers, command]);
121121
const setCommandUserId = useCallback(
122-
(userId) => {
122+
(userId: number) => {
123123
const user = commandReceivers.find((u) => u.userId === userId);
124124
if (user !== undefined) {
125125
setCommandUser(user);

src/feature/command/component/cmd-receiver.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const CommandReceiverContainer = (props: CommandReceiverProps) => {
3333
));
3434

3535
const onMenuItemClick = useCallback(
36-
({ key }) => {
36+
({ key }: { key: string }) => {
3737
const userId = Number(key);
3838
if (userId !== selectedChatUser?.userId) {
3939
setCommandUser(userId);

src/feature/video/components/audio-video-statistic.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import { useCallback, useContext, useEffect, useRef, useState } from "react";
22

3-
import { AudioQosData, VideoQosData } from "@zoom/videosdk";
3+
import {
4+
AudioQosData,
5+
VideoQosData,
6+
event_audio_statistic_data_change,
7+
event_video_statistic_data_change,
8+
} from "@zoom/videosdk";
49
import { Modal, Table, Tabs } from "antd";
510

611
import MediaContext from "../../../context/media-context";
712
import ZoomContext from "../../../context/zoom-context";
813
import { useMount, useUnmount } from "../../../hooks";
14+
915
interface AudioVideoStatisticModelProps {
1016
visible: boolean;
1117
defaultTab?: string;
@@ -180,7 +186,7 @@ const AudioVideoStatisticModel = (props: AudioVideoStatisticModelProps) => {
180186
}
181187
};
182188

183-
const onAudioStatisticChange = useCallback((payload) => {
189+
const onAudioStatisticChange = useCallback((payload: Parameters<typeof event_audio_statistic_data_change>[0]) => {
184190
const {
185191
data: { encoding, ...restProps },
186192
} = payload;
@@ -195,7 +201,8 @@ const AudioVideoStatisticModel = (props: AudioVideoStatisticModelProps) => {
195201
}, 2000);
196202
}
197203
}, []);
198-
const onVideoStatisticChange = useCallback((payload) => {
204+
205+
const onVideoStatisticChange = useCallback((payload: Parameters<typeof event_video_statistic_data_change>[0]) => {
199206
const {
200207
data: { encoding, ...restProps },
201208
} = payload;

src/feature/video/components/video-footer.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import {
88
PhoneCallCountry,
99
RecordingStatus,
1010
VideoCapturingState,
11+
event_current_audio_change,
12+
event_dial_out_change,
13+
event_passively_stop_share,
14+
event_share_audio_change,
15+
event_video_capturing_change,
1116
} from "@zoom/videosdk";
1217
import { message } from "antd";
1318
import classNames from "classnames";
@@ -158,21 +163,23 @@ const VideoFooter = (props: VideoFooterProps) => {
158163
}
159164
return Promise.resolve();
160165
};
161-
const onHostAudioMuted = useCallback((payload) => {
166+
const onHostAudioMuted = useCallback((payload: Parameters<typeof event_current_audio_change>[0]) => {
162167
const { action, source, type } = payload;
163168
if (action === AudioChangeAction.Join) {
164169
setIsStartedAudio(true);
165-
setAudio(type);
170+
if (type !== undefined) {
171+
setAudio(type);
172+
}
166173
} else if (action === AudioChangeAction.Leave) {
167174
setIsStartedAudio(false);
168175
} else if (action === AudioChangeAction.Muted) {
169176
setIsMuted(true);
170177
if (source === MutedSource.PassiveByMuteOne) {
171178
message.info("Host muted you");
172179
}
173-
} else if (action === AudioChangeAction.Unmuted) {
180+
} else {
174181
setIsMuted(false);
175-
if (source === "passive") {
182+
if (source === MutedSource.PassiveByMuteAll || source === MutedSource.PassiveByMuteOne) {
176183
message.info("Host unmuted you");
177184
}
178185
}
@@ -186,10 +193,12 @@ const VideoFooter = (props: VideoFooterProps) => {
186193
setIsStartedScreenShare(false);
187194
}
188195
}, [mediaStream, isStartedScreenShare, shareRef]);
189-
const onPassivelyStopShare = useCallback(({ reason }) => {
196+
197+
const onPassivelyStopShare = useCallback((reason: Parameters<typeof event_passively_stop_share>[0]) => {
190198
console.info("passively stop reason:", reason);
191199
setIsStartedScreenShare(false);
192200
}, []);
201+
193202
const onDeviceChange = useCallback(() => {
194203
if (mediaStream !== null) {
195204
setMicList(mediaStream.getMicList());
@@ -205,7 +214,7 @@ const VideoFooter = (props: VideoFooterProps) => {
205214
setRecordingStatus(recordingClient?.getCloudRecordingStatus() ?? "");
206215
}, [recordingClient]);
207216

208-
const onDialOutChange = useCallback((payload) => {
217+
const onDialOutChange = useCallback((payload: Parameters<typeof event_dial_out_change>[0]) => {
209218
setPhoneCallStatus(payload.code);
210219
}, []);
211220

@@ -235,18 +244,18 @@ const VideoFooter = (props: VideoFooterProps) => {
235244
}
236245
}
237246
};
238-
const onVideoCaptureChange = useCallback((payload) => {
247+
const onVideoCaptureChange = useCallback((payload: Parameters<typeof event_video_capturing_change>[0]) => {
239248
if (payload.state === VideoCapturingState.Started) {
240249
setIsStartedVideo(true);
241250
} else {
242251
setIsStartedVideo(false);
243252
}
244253
}, []);
245-
const onShareAudioChange = useCallback((payload) => {
254+
const onShareAudioChange = useCallback((payload: Parameters<typeof event_share_audio_change>[0]) => {
246255
const { state } = payload;
247256
if (state === "on") {
248257
setIsComputerAudioDisabled(true);
249-
} else if (state === "off") {
258+
} else {
250259
setIsComputerAudioDisabled(false);
251260
}
252261
}, []);

src/feature/video/hooks/useAvtiveVideo.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
import { useCallback, useEffect, useState } from "react";
22

3+
import { event_audio_active_speaker, event_video_active_change } from "@zoom/videosdk";
4+
35
import { ZoomClient } from "../../../index-types.d";
6+
47
export function useActiveVideo(zmClient: ZoomClient) {
58
const [activeVideo, setActiveVideo] = useState<number>(0);
69
const [activeSpeaker, setActiveSpeaker] = useState<number>(0);
7-
const onVideoActiveChange = useCallback((payload) => {
10+
11+
const onVideoActiveChange = useCallback((payload: Parameters<typeof event_video_active_change>[0]) => {
812
const { state, userId } = payload;
913
if (state === "Active") {
1014
setActiveVideo(userId);
11-
} else if (state === "Inactive") {
15+
} else {
1216
setActiveVideo(0);
1317
}
1418
}, []);
15-
const onActiveSpeakerChange = useCallback((payload) => {
16-
if (Array.isArray(payload) && payload.length > 0) {
17-
const { userId } = payload[0];
18-
setActiveSpeaker(userId);
19+
20+
const onActiveSpeakerChange = useCallback((payload: Parameters<typeof event_audio_active_speaker>[0]) => {
21+
const activeSpeaker = payload[0];
22+
if (activeSpeaker !== undefined) {
23+
setActiveSpeaker(activeSpeaker.userId);
1924
}
2025
}, []);
26+
2127
useEffect(() => {
2228
zmClient.on("video-active-change", onVideoActiveChange);
2329
zmClient.on("active-speaker", onActiveSpeakerChange);

src/feature/video/hooks/useCanvasDimension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function useCanvasDimension(
99
videoRef: MutableRefObject<HTMLCanvasElement | null>,
1010
) {
1111
const [dimension, setDimension] = useState({ width: 0, height: 0 });
12-
const onCanvasResize = useCallback(({ width, height }) => {
12+
const onCanvasResize = useCallback(({ width, height }: { width: number; height: number }) => {
1313
_.debounce((...args) => {
1414
setDimension({
1515
width: args[0],

0 commit comments

Comments
 (0)