Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f4157e

Browse files
added home server url to data fields
1 parent1976ab4 commit9f4157e

File tree

3 files changed

+57
-40
lines changed

3 files changed

+57
-40
lines changed

‎client/packages/lowcoder/src/comps/comps/chatroom/chatControllerComp.tsx

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ const EventOptions = [closeEvent] as const;
5454
constDEFAULT_SIZE=378;
5555
constDEFAULT_PADDING=16;
5656

57-
exportconstmatrixClient:MatrixClient=sdk.createClient({
58-
baseUrl:"https://matrix.safiricabs.com",
59-
});
57+
exportletmatrixClient:any=null;
6058

6159
constDrawerWrapper=styled.div`
6260
// Shield the mouse events of the lower layer, the mask can be closed in the edit mode to prevent the lower layer from sliding
@@ -109,6 +107,7 @@ export const meetingControllerChildren = {
109107
showMask:withDefault(BoolControl,true),
110108
credentials:withDefault(StringControl,trans("chat.credentials")),
111109
roomAlias:withDefault(StringControl,""),
110+
matrixServerUrl:withDefault(StringControl,""),
112111
roomData:jsonObjectExposingStateControl(""),
113112
messages:stateComp<JSONValue>([]),
114113
participants:stateComp<JSONValue>([]),
@@ -140,8 +139,6 @@ let MTComp = (function () {
140139
[dispatch,isTopBom]
141140
);
142141

143-
144-
145142
useEffect(()=>{
146143
if(props.matrixAuthData.value.access_token==null)return;
147144
resourcesInit();
@@ -150,8 +147,8 @@ let MTComp = (function () {
150147
useEffect(()=>{
151148
if(props.roomData.value.roomId){
152149
matrixClient
153-
.joinRoom(`${props.roomData.value.roomId}`)
154-
.then(async(room)=>{
150+
?.joinRoom(`${props.roomData.value.roomId}`)
151+
.then(async(room:{getMembers:()=>any})=>{
155152
letmembers=room.getMembers();
156153
letparticipants:any=[];
157154
members.forEach((element:sdk.RoomMember)=>{
@@ -169,7 +166,13 @@ let MTComp = (function () {
169166
);
170167

171168
matrixClient.scrollback(room,10).then(
172-
function(room){
169+
function(room:{
170+
getLiveTimeline:()=>{
171+
():any;
172+
new():any;
173+
getEvents:{():any;new():any};
174+
};
175+
}){
173176
letmessagesdata:any=[];
174177
varevents=room.getLiveTimeline().getEvents();
175178
for(vari=0;i<events.length;i++){
@@ -207,12 +210,12 @@ let MTComp = (function () {
207210

208211
dispatchMessages(messagesdata);
209212
},
210-
function(err){
213+
function(err:any){
211214
console.log("/more Error: %s",err);
212215
}
213216
);
214217
})
215-
.catch((e)=>console.log(e));
218+
.catch((e:any)=>console.log(e));
216219
letmessagesdata:any=[];
217220
matrixClient.on(
218221
"Room.timeline"assdk.EmittedEvents,
@@ -239,7 +242,6 @@ let MTComp = (function () {
239242
}
240243
},[props.roomData.value]);
241244

242-
243245
letresourcesInit=()=>{
244246
// show the room list after syncing.
245247
matrixClient.on(
@@ -277,7 +279,6 @@ let MTComp = (function () {
277279
);
278280
};
279281

280-
281282
return(
282283
<BackgroundColorContext.Providervalue={props.style.background}>
283284
<DrawerWrapper>
@@ -340,7 +341,7 @@ let MTComp = (function () {
340341
</DrawerWrapper>
341342
</BackgroundColorContext.Provider>
342343
);
343-
}
344+
}
344345
)
345346
.setPropertyViewFn((children)=>(
346347
<>
@@ -369,6 +370,9 @@ let MTComp = (function () {
369370
{children.showMask.propertyView({
370371
label:trans("prop.showMask"),
371372
})}
373+
{children.matrixServerUrl.propertyView({
374+
label:trans("prop.matrixServerUrl"),
375+
})}
372376
</Section>
373377
<Sectionname={sectionNames.chats}>
374378
{children.roomAlias.propertyView({
@@ -410,15 +414,14 @@ MTComp = withMethodExposing(MTComp, [
410414
params:[],
411415
},
412416
execute:async(comp,values)=>{
413-
console.log(values);
417+
console.log(values);
414418
if(values&&values.length>0){
415419
constfirstValue=values[0];
416420
if(
417421
typeoffirstValue==="object"&&
418422
firstValue!==null&&
419423
"name"infirstValue
420-
){
421-
console.log(firstValue);
424+
){
422425
constname:any=firstValue.name;
423426
consttopic:any=firstValue.topic;
424427
// Create a room
@@ -428,11 +431,10 @@ MTComp = withMethodExposing(MTComp, [
428431
name:name,
429432
topic:topic,
430433
})
431-
.then((response)=>{
434+
.then((response:{room_id:any})=>{
432435
constroomId=response.room_id;
433-
console.log(`Created room:${roomId}`);
434436
})
435-
.catch((error)=>{
437+
.catch((error:{message:any})=>{
436438
console.error(`Failed to create room:${error.message}`);
437439
});
438440
}else{
@@ -466,7 +468,7 @@ MTComp = withMethodExposing(MTComp, [
466468
.then(()=>{
467469
console.log(`Left room:${name}`);
468470
})
469-
.catch((error)=>{
471+
.catch((error:{message:any})=>{
470472
console.error(`Failed to leave room:${error.message}`);
471473
});
472474
}else{
@@ -515,27 +517,39 @@ MTComp = withMethodExposing(MTComp, [
515517
params:[],
516518
},
517519
execute:async(comp,values)=>{
518-
letresponse=awaitmatrixClient.login("org.matrix.login.jwt",{
519-
token:values[0],
520-
});
521-
awaitmatrixClient.startClient();
522-
523-
letallRooms=awaitmatrixClient.publicRooms();
524-
525-
letrooms:any=[];
526-
allRooms.chunk.forEach((room)=>{
527-
rooms.push({
528-
name:room.name,
529-
roomId:room.room_id,
530-
membersCount:room.num_joined_members.toString(),
520+
leturl=`https://${comp.children.matrixServerUrl.getView()}`;
521+
if(comp.children.matrixServerUrl.getView()){
522+
matrixClient=sdk.createClient({
523+
baseUrl:url,
531524
});
532-
});
525+
letresponse=awaitmatrixClient.login("org.matrix.login.jwt",{
526+
token:values[0],
527+
});
528+
awaitmatrixClient.startClient();
529+
530+
letallRooms=awaitmatrixClient.publicRooms();
531+
532+
letrooms:any=[];
533+
allRooms.chunk.forEach(
534+
(room:{
535+
name:any;
536+
room_id:any;
537+
num_joined_members:{toString:()=>any};
538+
})=>{
539+
rooms.push({
540+
name:room.name,
541+
roomId:room.room_id,
542+
membersCount:room.num_joined_members.toString(),
543+
});
544+
}
545+
);
533546

534-
comp.children.matrixAuthData.change({
535-
access_token:response.access_token,
536-
user_id:response.user_id,
537-
rooms,
538-
});
547+
comp.children.matrixAuthData.change({
548+
access_token:response.access_token,
549+
user_id:response.user_id,
550+
rooms,
551+
});
552+
}
539553
},
540554
},
541555
{
@@ -557,4 +571,5 @@ export const ChatControllerComp = withExposingConfigs(MTComp, [
557571
newNameConfig("messages",""),
558572
newNameConfig("participants",""),
559573
newNameConfig("roomLists",""),
574+
newNameConfig("matrixServerUrl",""),
560575
]);

‎client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export const en = {
198198
maskClosable:"Click Outside to Close",
199199
showMask:"Show Mask",
200200
textOverflow:"Text Overflow",
201+
matrixServerUrl:"Matrix Server Url",
201202
},
202203
autoHeightProp:{
203204
auto:"Auto",

‎client/packages/lowcoder/src/i18n/locales/translation_files/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@
180180
"showBody":"Show Body",
181181
"showFooter":"Show Footer",
182182
"maskClosable":"Click Outside to Close",
183-
"showMask":"Show Mask"
183+
"showMask":"Show Mask",
184+
"matrixServerUrl":"Matrix Server Url"
184185
},
185186
"autoHeightProp": {
186187
"auto":"Auto",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp