Skip to content

Commit 5017338

Browse files
renaming refactoring of the components
1 parent 82c198b commit 5017338

File tree

7 files changed

+10
-396
lines changed

7 files changed

+10
-396
lines changed

client/packages/lowcoder/src/comps/hooks/videoControllerComp.tsx renamed to client/packages/lowcoder/src/comps/comps/meetingComp/videoControllerComp.tsx

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ import {
88
import { AutoHeightControl } from "comps/controls/autoHeightControl";
99
import { BoolControl } from "comps/controls/boolControl";
1010
import {
11-
JSONObjectArrayControl,
12-
NumberControl,
1311
StringControl,
1412
} from "comps/controls/codeControl";
1513
import {
16-
arrayStringExposingStateControl,
1714
booleanExposingStateControl,
1815
jsonObjectExposingStateControl,
1916
jsonValueExposingStateControl,
@@ -39,22 +36,19 @@ import {
3936
Section,
4037
sectionNames,
4138
} from "lowcoder-design";
42-
import { useCallback, useEffect, useState } from "react";
39+
import { useCallback, useEffect } from "react";
4340
import { ResizeHandle } from "react-resizable";
4441
import styled from "styled-components";
4542
import { useUserViewMode } from "util/hooks";
4643
import { isNumeric } from "util/stringUtils";
47-
import { NameConfig, withExposingConfigs } from "../generators/withExposing";
48-
import { v4 as uuidv4 } from "uuid";
44+
import { NameConfig, withExposingConfigs } from "../../generators/withExposing";
4945

5046
import AgoraRTC, {
5147
ICameraVideoTrack,
5248
IMicrophoneAudioTrack,
5349
IAgoraRTCClient,
5450
IAgoraRTCRemoteUser,
55-
IRemoteVideoTrack,
5651
} from "agora-rtc-sdk-ng";
57-
import { JSONObject } from "@lowcoder-ee/index.sdk";
5852

5953
const EventOptions = [closeEvent] as const;
6054

@@ -100,24 +94,6 @@ function transToPxSize(size: string | number) {
10094
return isNumeric(size) ? size + "px" : (size as string);
10195
}
10296

103-
const PlacementOptions = [
104-
{
105-
label: trans("drawer.top"),
106-
value: "top",
107-
},
108-
{
109-
label: trans("drawer.right"),
110-
value: "right",
111-
},
112-
{
113-
label: trans("drawer.bottom"),
114-
value: "bottom",
115-
},
116-
{
117-
label: trans("drawer.left"),
118-
value: "left",
119-
},
120-
] as const;
12197

12298
let client: IAgoraRTCClient = AgoraRTC.createClient({
12399
mode: "rtc",
@@ -144,8 +120,6 @@ const turnOnMicrophone = async (flag?: boolean) => {
144120
};
145121

146122
const leaveChannel = async () => {
147-
console.log("isJoined", isJoined);
148-
149123
if (!client) {
150124
console.error("Agora client is not initialized");
151125
return;
@@ -156,19 +130,19 @@ const leaveChannel = async () => {
156130
return;
157131
}
158132
if (videoTrack) {
159-
// await turnOnCamera(false);
133+
await turnOnCamera(false);
160134
await client.unpublish(videoTrack);
161135
videoTrack.stop();
162136
}
163137

164138
if (audioTrack) {
165-
// await turnOnMicrophone(false);
139+
await turnOnMicrophone(false);
166140
await client.unpublish(audioTrack);
167141
audioTrack.stop();
168142
}
169143

170144
await client.leave();
171-
isJoined = false; // Update the flag to indicate that you have left the channel
145+
isJoined = false;
172146
};
173147
let isJoined = false;
174148

@@ -181,8 +155,6 @@ const joinChannel = async (appId: any, channel: any, token: any) => {
181155
await leaveChannel();
182156
}
183157

184-
// client.on("user-published", onUserPublish);
185-
186158
await client.join(
187159
appId,
188160
channel,
@@ -194,19 +166,14 @@ const joinChannel = async (appId: any, channel: any, token: any) => {
194166
};
195167

196168
const publishVideo = async (appId: any, channel: any, height: any) => {
197-
console.log("publishVideo", appId, channel, isJoined);
198169
await turnOnCamera(true);
199170
console.log(appId, channel);
200171

201172
if (!isJoined) {
202173
await joinChannel(appId, channel, null);
203174
}
204175

205-
console.log("publish videoTrack ", videoTrack);
206-
207176
await client.publish(videoTrack);
208-
209-
// turnOnCamera(true);
210177
const mediaStreamTrack = videoTrack.getMediaStreamTrack();
211178

212179
if (mediaStreamTrack) {
@@ -276,16 +243,12 @@ let MTComp = (function () {
276243
[dispatch, isTopBom]
277244
);
278245

279-
const usersWithVideoTracks: any = {};
280-
281246
useEffect(() => {
282247
console.log("nnnn ", props.participants);
283248
}, [props.participants.value]);
284249

285250
useEffect(() => {
286251
if (client) {
287-
console.log("REGISTERING LISTNERS");
288-
289252
client.on(
290253
"user-published",
291254
async (user: IAgoraRTCRemoteUser, mediaType: "video" | "audio") => {
@@ -297,26 +260,10 @@ let MTComp = (function () {
297260
const remoteTrack = await client.subscribe(user, mediaType);
298261
remoteTrack.play();
299262
}
300-
const remoteVideoTrack = user.videoTrack;
301-
if (remoteVideoTrack) {
302-
props.participants.onChange([JSON.stringify(user.uid)]);
303-
console.log("usersWithVideoTracks", props.participants);
304-
}
305263
}
306264
);
307265

308-
client.on("user-joined", (user: IAgoraRTCRemoteUser) => {
309-
// usersWithVideoTracks[user.uid] = { user, videoTracks: [] };
310-
// props.participants.onChange(usersWithVideoTracks);
311-
// console.log(
312-
// "userJoined",
313-
// user.uid,
314-
// props.participants.value,
315-
// usersWithVideoTracks
316-
// );
317-
// const uid = user.uid;
318-
// usersWithVideoTracks[uid] = { user, videoTracks: [] };
319-
});
266+
client.on("user-joined", (user: IAgoraRTCRemoteUser) => {});
320267
client.on("user-offline", (uid: any, reason: any) => {
321268
console.log(`User ${uid} left the channel.`);
322269
});
@@ -328,13 +275,8 @@ let MTComp = (function () {
328275
});
329276
client.on("stream-added", (user: IAgoraRTCRemoteUser) => {
330277
console.log("stream-added");
331-
332-
if (user.hasVideo) {
333-
console.log(`Stream from user ${user.videoTrack} added.`);
334-
}
335278
});
336279
}
337-
// turnOnCamera(true);
338280
}, [client]);
339281

340282
return (

client/packages/lowcoder/src/comps/comps/videoComp/videoMeetingComp.tsx renamed to client/packages/lowcoder/src/comps/comps/meetingComp/videoStreamComp.tsx

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -165,31 +165,19 @@ let VideoCompBuilder = (function (props) {
165165
suffixIcon: IconControl,
166166
style: ButtonStyleControl,
167167
viewRef: RefControl<HTMLElement>,
168-
appId: withDefault(StringControl, trans("prop.appid")), ///
169-
videokey: withDefault(StringControl, trans("prop.videokey")),
170-
participants: arrayStringExposingStateControl("participants"),
171168
userId: stringExposingStateControl(
172169
"text",
173170
trans("meeting.userId", { name: "{{currentUser.name}}" })
174171
),
175172
};
176-
// const { client, videoHeight, videoWidth, setHeight, setWidth } = useAgora();
177-
178173
return new UICompBuilder(childrenMap, (props) => {
179-
console.log("userId", props.userId.value);
180-
// "afd10eabe68a4de68a76461be92c693c"
181174
const videoRef = useRef<HTMLVideoElement>(null);
182175
const conRef = useRef<HTMLDivElement>(null);
183176

184177
useEffect(() => {
185178
onResize();
186179
}, []);
187180

188-
useEffect(() => {
189-
if (props.participants.value.length > 0) {
190-
console.log("bbb", props.participants.value);
191-
}
192-
}, [props.participants.value]);
193181

194182
const onResize = async () => {
195183
const container = conRef.current;
@@ -205,7 +193,6 @@ let VideoCompBuilder = (function (props) {
205193
<Container ref={conRef} $style={props.style}>
206194
<video
207195
ref={videoRef}
208-
id={props.videokey}
209196
style={{ width: 300, height: 300 }}
210197
></video>
211198
</Container>
@@ -216,46 +203,6 @@ let VideoCompBuilder = (function (props) {
216203
})
217204
.setPropertyViewFn((children) => (
218205
<>
219-
{/* <Section name={sectionNames.settings}>
220-
{children.userId.propertyView({
221-
label: trans("meeting.userId"),
222-
})}
223-
{children.autoHeight.getPropertyView()}
224-
{children.videokey.propertyView({
225-
label: trans("prop.videokey"),
226-
})}
227-
</Section> */}
228-
{/* <Section name={sectionNames.layout}>
229-
{/* {hiddenPropertyView(children)}
230-
</Section> */}
231-
232-
{/* <Section name={sectionNames.interaction}>
233-
{children.type.propertyView({
234-
label: trans("prop.type"),
235-
radioButton: true,
236-
})} */}
237-
{/* {isDefault(children.type.getView())
238-
? [
239-
children.onEvent.getPropertyView(),
240-
disabledPropertyView(children),
241-
loadingPropertyView(children),
242-
]
243-
: children.form.getPropertyView()} */}
244-
{/* </Section> */}
245-
246-
{/* <Section name={sectionNames.layout}>
247-
{children.prefixIcon.propertyView({
248-
label: trans("button.prefixIcon"),
249-
})}
250-
{children.suffixIcon.propertyView({
251-
label: trans("button.suffixIcon"),
252-
})}
253-
{hiddenPropertyView(children)}
254-
</Section>
255-
256-
<Section name={sectionNames.style}>
257-
{children.style.getPropertyView()}
258-
</Section> */}
259206
</>
260207
))
261208
.build();
@@ -267,57 +214,8 @@ VideoCompBuilder = class extends VideoCompBuilder {
267214
}
268215
};
269216

270-
VideoCompBuilder = withMethodExposing(VideoCompBuilder, [
271-
{
272-
method: {
273-
name: "audioControl",
274-
description: trans("meeting.actionBtnDesc"),
275-
params: [],
276-
},
277-
execute: (comp, values) => {
278-
// let value = !comp.children.audioControl.getView().value;
279-
// turnOnMicrophone(value);
280-
// comp.children.audioControl.change(value);
281-
},
282-
},
283-
// {
284-
// method: {
285-
// name: "videoControl",
286-
// description: trans("meeting.actionBtnDesc"),
287-
// params: [],
288-
// },
289-
// execute: (comp, values) => {
290-
// let value = !comp.children.videoControl.getView().value;
291-
// turnOnCamera(value);
292-
// comp.children.videoControl.change(value);
293-
// },
294-
// },
295-
// {
296-
// method: {
297-
// name: "startMeeting",
298-
// description: trans("meeting.actionBtnDesc"),
299-
// params: [],
300-
// },
301-
// execute: (comp, values) => {
302-
// publishVideo(comp.children.appId.getView(), "testsdaadasdsa");
303-
// },
304-
// },
305-
// {
306-
// method: {
307-
// name: "endCall",
308-
// description: trans("meeting.actionBtnDesc"),
309-
// params: [],
310-
// },
311-
// execute: (comp, values) => {
312-
// let value = !comp.children.endCall.getView().value;
313-
// leaveChannel();
314-
// comp.children.endCall.change(value);
315-
// },
316-
// },
317-
]);
318217

319218
export const VideoMeetingComp = withExposingConfigs(VideoCompBuilder, [
320-
// new NameConfig("appId", trans("button.textDesc")),
321219
new NameConfig("loading", trans("button.loadingDesc")),
322220
...CommonNameConfig,
323221
]);

0 commit comments

Comments
 (0)