Fix code style

This commit is contained in:
Dylan 2022-08-30 18:37:25 +09:30
parent 459987b2b3
commit 4ff1aa3813

View file

@ -29,7 +29,7 @@ function JoinAliasContent({ term, requestClose }) {
const [error, setError] = useState(undefined);
const [lastJoinId, setLastJoinId] = useState(undefined);
const [preview, setPreview] = useState(undefined);
const [loadingPreview, setLoadingPreview] = useState(undefined)
const [loadingPreview, setLoadingPreview] = useState(undefined);
const [debounce] = useState(new Debounce());
const mx = initMatrix.matrixClient;
@ -60,27 +60,26 @@ function JoinAliasContent({ term, requestClose }) {
setPreview(undefined);
debounce._(async () => {
try {
let room_id = text;
let roomId = text;
if(text.startsWith('#')){
if (text.startsWith('#')) {
const room = await mx.resolveRoomAlias(text);
room_id = room.room_id;
roomId = room.room_id;
}
roomData = await mx.getRoom(room_id)
setLoadingPreview(false)
setPreview(roomData)
roomData = await mx.getRoom(roomId);
setLoadingPreview(false);
setPreview(roomData);
} catch {
setLoadingPreview(false);
setPreview(undefined);
}
catch{
setLoadingPreview(false)
setPreview(undefined)
}
}, 500)();
}
};
if(loadingPreview === undefined && term)
loadPreview(term)
if (loadingPreview === undefined && term) {
loadPreview(term);
}
const handleSubmit = async (e) => {
e.preventDefault();
@ -119,8 +118,9 @@ function JoinAliasContent({ term, requestClose }) {
}
};
if(term && loadingPreview === undefined)
if (term && loadingPreview === undefined) {
loadPreview(term);
}
return (
<form className="join-alias" onSubmit={handleSubmit}>
@ -132,14 +132,15 @@ function JoinAliasContent({ term, requestClose }) {
onChange={(e) => (loadPreview(e.target.value))}
/>
{error && <Text className="join-alias__error" variant="b3">{error}</Text>}
{ loadingPreview ? <Spinner></Spinner> : <></> }
{ preview ? <RoomTile
key={preview.roomId}
name={preview.name}
avatarSrc={initMatrix.matrixClient.getRoom(preview.roomId).getAvatarUrl(initMatrix.matrixClient.baseUrl, 42, 42, 'crop')}
id={preview.roomId}
/> : <></>
}
{ 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
@ -183,7 +184,6 @@ function useWindowToggle() {
function JoinAlias() {
const [data, requestClose] = useWindowToggle();
const [loaded, setLoaded] = useState(null);
return (
<Dialog