Skip to content

Commit 21aa2bb

Browse files
feat: added set username and Fix: dublicate events
1 parent b9bce7c commit 21aa2bb

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingControllerComp.tsx

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import {
1212
booleanExposingStateControl,
1313
jsonObjectExposingStateControl,
1414
numberExposingStateControl,
15+
numberStateControl,
1516
stringExposingStateControl,
17+
stringStateControl,
1618
} from "comps/controls/codeStateControl";
1719
import { PositionControl } from "comps/controls/dropdownControl";
1820
import {
@@ -274,13 +276,14 @@ export const meetingControllerChildren = {
274276
endCall: booleanExposingStateControl("false"),
275277
sharing: booleanExposingStateControl("false"),
276278
videoSettings: jsonObjectExposingStateControl(""),
277-
videoWidth: numberExposingStateControl("videoWidth", 200),
278-
videoHeight: numberExposingStateControl("videoHeight", 200),
279+
videoWidth: numberStateControl(200),
280+
videoHeight: numberStateControl(200),
279281
appId: withDefault(StringControl, trans("meeting.appid")),
280282
participants: stateComp<JSONValue>([]),
281283
usersScreenShared: stateComp<JSONValue>([]),
282284
localUser: jsonObjectExposingStateControl(""),
283-
meetingName: stringExposingStateControl("meetingName"),
285+
meetingName: stringStateControl("meetingName"),
286+
userName: stringStateControl("userName"),
284287
certifiCateKey: stringExposingStateControl(""),
285288
messages: stateComp<JSONValue>([]),
286289
};
@@ -314,6 +317,12 @@ let MTComp = (function () {
314317
);
315318
}, [userIds]);
316319

320+
useEffect(() => {
321+
dispatch(
322+
changeChildAction("participants", getData(userIds).data, false)
323+
);
324+
}, [userIds]);
325+
317326
useEffect(() => {
318327
if (props.endCall.value) {
319328
let newUsers = userIds.filter((item: any) => item.user !== userId);
@@ -331,6 +340,19 @@ let MTComp = (function () {
331340
}
332341
}, [rtmMessages]);
333342

343+
useEffect(() => {
344+
if (props.localUser.value) {
345+
let newUsers = userIds.filter((item: any) => item.user !== userId);
346+
if (newUsers.length == 0) return;
347+
newUsers = props.localUser.value;
348+
let updatedUsers = [...userIds, newUsers];
349+
console.log("updatedUsers", updatedUsers);
350+
dispatch(
351+
changeChildAction("participants", getData(updatedUsers).data, false)
352+
);
353+
}
354+
}, [props.localUser.value]);
355+
334356
useEffect(() => {
335357
if (rtmChannelResponse) {
336358
rtmClient.on("MessageFromPeer", function (message, peerId) {
@@ -526,7 +548,6 @@ MTComp = withMethodExposing(MTComp, [
526548
user: userId + "",
527549
audiostatus: value,
528550
});
529-
console.log(localUserData);
530551
await turnOnMicrophone(value);
531552
comp.children.audioControl.change(value);
532553
},
@@ -583,13 +604,12 @@ MTComp = withMethodExposing(MTComp, [
583604

584605
let message: any = {
585606
time: Date.now(),
586-
from: userId,
607+
from: comp.children.localUser.getView().value,
587608
};
588609
message["data"] = otherData;
589610

590611
if (toUsers.length > 0 && toUsers[0] !== undefined) {
591612
let peers = toUsers?.map((u: any) => u.user);
592-
console.log("peers", peers);
593613
peers.forEach((p: any) => {
594614
sendPeerMessageRtm(message, String(p));
595615
});
@@ -598,6 +618,29 @@ MTComp = withMethodExposing(MTComp, [
598618
}
599619
},
600620
},
621+
{
622+
method: {
623+
name: "setMeetingName",
624+
description: trans("meeting.meetingName"),
625+
params: [],
626+
},
627+
execute: async (comp, values) => {
628+
let meetingName: any = values[0];
629+
comp.children.meetingName.change(meetingName);
630+
},
631+
},
632+
{
633+
method: {
634+
name: "setUserName",
635+
description: trans("meeting.meetingName"),
636+
params: [],
637+
},
638+
execute: async (comp, values) => {
639+
let userName: any = values[0];
640+
let userLocal = comp.children.localUser.getView().value;
641+
comp.children.localUser.change({ ...userLocal, userName: userName });
642+
},
643+
},
601644
{
602645
method: {
603646
name: "endMeeting",

0 commit comments

Comments
 (0)