No known servers on channel join bug fixed

This commit is contained in:
unknown 2021-08-15 22:25:07 +05:30
parent 7fddf80c09
commit 419e25df23
3 changed files with 7 additions and 6 deletions

View file

@ -230,7 +230,7 @@ function InviteUser({
>
<div className="invite-user">
<form className="invite-user__form" onSubmit={(e) => { e.preventDefault(); searchUser(usernameRef.current.value); }}>
<Input value={searchTerm} forwardRef={usernameRef} label="Username or userId" />
<Input value={searchTerm} forwardRef={usernameRef} label="Name or userId" />
<Button disabled={isSearching} iconSrc={UserIC} variant="primary" type="submit">Search</Button>
</form>
<div className="invite-user__search-status">

View file

@ -177,10 +177,10 @@ function PublicChannels({ isOpen, searchTerm, onRequestClose }) {
onRequestClose();
}
function joinChannel(roomId) {
joiningChannels.add(roomId);
function joinChannel(roomIdOrAlias) {
joiningChannels.add(roomIdOrAlias);
updateJoiningChannels(new Set(Array.from(joiningChannels)));
roomActions.join(roomId, false);
roomActions.join(roomIdOrAlias, false);
}
function renderChannelList(channels) {
@ -199,7 +199,7 @@ function PublicChannels({ isOpen, searchTerm, onRequestClose }) {
options={(
<>
{isJoined && <Button onClick={() => handleViewChannel(channel.room_id)}>Open</Button>}
{!isJoined && (joiningChannels.has(channel.room_id) ? <Spinner size="small" /> : <Button onClick={() => joinChannel(channel.room_id)} variant="primary">Join</Button>)}
{!isJoined && (joiningChannels.has(channel.room_id) ? <Spinner size="small" /> : <Button onClick={() => joinChannel(channel.aliases?.[0] || channel.room_id)} variant="primary">Join</Button>)}
</>
)}
/>

View file

@ -85,8 +85,9 @@ function guessDMRoomTargetId(room, myUserId) {
*/
async function join(roomIdOrAlias, isDM) {
const mx = initMatrix.matrixClient;
const roomIdParts = roomIdOrAlias.split(':');
try {
const resultRoom = await mx.joinRoom(roomIdOrAlias);
const resultRoom = await mx.joinRoom(roomIdOrAlias, { viaServers: [roomIdParts[1]] });
if (isDM) {
const targetUserId = guessDMRoomTargetId(mx.getRoom(resultRoom.roomId), mx.getUserId());