improve chat things
This commit is contained in:
parent
8bc897a1e7
commit
933701433c
1 changed files with 7 additions and 4 deletions
|
@ -113,7 +113,7 @@ export default function Home() {
|
|||
/* SECT: LHUA; Lord help us all these ones */
|
||||
const [ textBox, setTextBox ] = useState<React.ReactNode>(null);
|
||||
let Message = useRef<(message:MessageType) => React.ReactNode>(() => <></>);
|
||||
const [, forceUpdate] = useState({});
|
||||
const [ affectedByUpdate, forceUpdate ] = useState({});
|
||||
const externCachedUsers = useRef(new Map());
|
||||
/* END_SECT LHUA; */
|
||||
|
||||
|
@ -169,6 +169,8 @@ export default function Home() {
|
|||
if (token != null)
|
||||
socket.emit('SIG_CHAT_JOIN', { token }, joinChatRes);
|
||||
|
||||
socket.emit('SIG_CHAT_CHANNELS', {}, channelsChatRes);
|
||||
|
||||
setTextBox(<div className={styles.textBox}>
|
||||
<textarea rows={2} className={styles.textBoxInput} ref={chatInput}></textarea>
|
||||
<button className={styles.textBoxButton} onClick={() => socket.emit('SIG_CHAT_MESSAGE', { message: chatInput.current?.value }, messageChatRes)}>Send</button>
|
||||
|
@ -195,7 +197,9 @@ export default function Home() {
|
|||
const timeSent = new Date(message.timestamp * 1000).toLocaleTimeString();
|
||||
return <div className={styles.Message} key={message.id}>
|
||||
<h3 className={styles.MessageHeader}>
|
||||
<a href={`/jams/user/${user?.id}`} target="_blank">{user?.username}@{user?.instance}</a>
|
||||
{user?.id != null ?
|
||||
<a href={`/jams/user/${user?.id}`} target="_blank">{user?.username}@{user?.instance}</a>
|
||||
: <i>Fetching user...</i>}
|
||||
{" "}
|
||||
<Conditional condition={canDelete}
|
||||
truthy={<button onClick={() => socket.emit('SIG_CHAT_RMMESSAGE', { messageId: message.id }, rmmessageChatRes)} className={styles.deleteButton}>
|
||||
|
@ -331,7 +335,6 @@ export default function Home() {
|
|||
setError(type, spec, data);
|
||||
} else {
|
||||
setWhoAmI(data);
|
||||
socket.emit('SIG_CHAT_CHANNELS', {}, channelsChatRes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,7 +388,7 @@ export default function Home() {
|
|||
</form>
|
||||
<p><small>Tested on Discord, GitHub, Mastodon, GoToSocial, Pleroma, and Misskey</small></p>
|
||||
</>);
|
||||
}, [messages]);
|
||||
}, [affectedByUpdate, messages]);
|
||||
|
||||
return (
|
||||
<ChatLayout
|
||||
|
|
Loading…
Reference in a new issue