Removed room preview
I realised it didnt work for rooms you weren't already in, rendering it useless
This commit is contained in:
parent
4ff1aa3813
commit
77e9a5bcc2
1 changed files with 0 additions and 47 deletions
|
@ -18,9 +18,6 @@ import Dialog from '../../molecules/dialog/Dialog';
|
|||
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
|
||||
|
||||
import { useStore } from '../../hooks/useStore';
|
||||
import RoomTile from '../../molecules/room-tile/RoomTile';
|
||||
|
||||
import { Debounce } from '../../../util/common';
|
||||
|
||||
const ALIAS_OR_ID_REG = /^[#|!].+:.+\..+$/;
|
||||
|
||||
|
@ -28,13 +25,9 @@ function JoinAliasContent({ term, requestClose }) {
|
|||
const [process, setProcess] = useState(false);
|
||||
const [error, setError] = useState(undefined);
|
||||
const [lastJoinId, setLastJoinId] = useState(undefined);
|
||||
const [preview, setPreview] = useState(undefined);
|
||||
const [loadingPreview, setLoadingPreview] = useState(undefined);
|
||||
const [debounce] = useState(new Debounce());
|
||||
|
||||
const mx = initMatrix.matrixClient;
|
||||
const mountStore = useStore();
|
||||
let roomData = null;
|
||||
|
||||
const openRoom = (roomId) => {
|
||||
const room = mx.getRoom(roomId);
|
||||
|
@ -55,32 +48,6 @@ function JoinAliasContent({ term, requestClose }) {
|
|||
};
|
||||
}, [lastJoinId]);
|
||||
|
||||
const loadPreview = async (text) => {
|
||||
setLoadingPreview(true);
|
||||
setPreview(undefined);
|
||||
debounce._(async () => {
|
||||
try {
|
||||
let roomId = text;
|
||||
|
||||
if (text.startsWith('#')) {
|
||||
const room = await mx.resolveRoomAlias(text);
|
||||
roomId = room.room_id;
|
||||
}
|
||||
|
||||
roomData = await mx.getRoom(roomId);
|
||||
setLoadingPreview(false);
|
||||
setPreview(roomData);
|
||||
} catch {
|
||||
setLoadingPreview(false);
|
||||
setPreview(undefined);
|
||||
}
|
||||
}, 500)();
|
||||
};
|
||||
|
||||
if (loadingPreview === undefined && term) {
|
||||
loadPreview(term);
|
||||
}
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
mountStore.setItem(true);
|
||||
|
@ -118,10 +85,6 @@ function JoinAliasContent({ term, requestClose }) {
|
|||
}
|
||||
};
|
||||
|
||||
if (term && loadingPreview === undefined) {
|
||||
loadPreview(term);
|
||||
}
|
||||
|
||||
return (
|
||||
<form className="join-alias" onSubmit={handleSubmit}>
|
||||
<Input
|
||||
|
@ -129,18 +92,8 @@ function JoinAliasContent({ term, requestClose }) {
|
|||
value={term}
|
||||
name="alias"
|
||||
required
|
||||
onChange={(e) => (loadPreview(e.target.value))}
|
||||
/>
|
||||
{error && <Text className="join-alias__error" variant="b3">{error}</Text>}
|
||||
{ loadingPreview ? <Spinner /> : null }
|
||||
{ preview ? (
|
||||
<RoomTile
|
||||
key={preview.roomId}
|
||||
name={preview.name}
|
||||
avatarSrc={initMatrix.matrixClient.getRoom(preview.roomId).getAvatarUrl(initMatrix.matrixClient.baseUrl, 42, 42, 'crop')}
|
||||
id={preview.roomId}
|
||||
/>
|
||||
) : null }
|
||||
<div className="join-alias__btn">
|
||||
{
|
||||
process
|
||||
|
|
Loading…
Reference in a new issue