This commit is contained in:
Timothy Jaeryang Baek 2024-12-31 02:42:46 -08:00
parent c8cdc6377b
commit 3da7ff1721

View File

@ -62,25 +62,33 @@
if (type === 'message') {
if ((data?.parent_id ?? null) === threadId) {
if (messages) {
messages = [data, ...messages];
if (typingUsers.find((user) => user.id === event.user.id)) {
typingUsers = typingUsers.filter((user) => user.id !== event.user.id);
}
}
}
} else if (type === 'message:update') {
if (messages) {
const idx = messages.findIndex((message) => message.id === data.id);
if (idx !== -1) {
messages[idx] = data;
}
}
} else if (type === 'message:delete') {
if (messages) {
messages = messages.filter((message) => message.id !== data.id);
}
} else if (type.includes('message:reaction')) {
if (messages) {
const idx = messages.findIndex((message) => message.id === data.id);
if (idx !== -1) {
messages[idx] = data;
}
}
} else if (type === 'typing' && event.message_id === threadId) {
if (event.user.id === $user.id) {
return;