Add editing messages

This commit is contained in:
2026-02-01 19:14:01 -07:00
parent 0cf9f6d07f
commit 2bfdcc9c90

View File

@@ -26,6 +26,7 @@ interface Message {
birdColor: BirdColor
overlayColor: BirdColor
customIcon: string | null
editing: boolean
}
interface CustomIconEntry {
@@ -178,7 +179,42 @@ export default function BerryDashChatroom () {
></img>
<div>
<p>{item.username}</p>
<p className='w-240 max-w-[calc(100vw-136px)] truncate select-text'>
<p
className='w-240 max-w-[calc(100vw-136px)] truncate select-text'
contentEditable={item.editing}
onDoubleClick={e => {
if (
Number(getCookie('accountId', '-1')) == item.userId
) {
setMessages(prev =>
prev.map(msg =>
msg.id === item.id
? {
...msg,
editing: !item.editing
}
: msg
)
)
if (item.editing) {
const text = e.currentTarget.textContent
e.currentTarget.textContent = atob(item.content)
ws?.send(
JSON.stringify({
type: 'edit',
kind: 'chatroom_message',
data: {
id: item.id,
newContent: text,
auth: token
},
timestamp: Date.now()
})
)
}
}
}}
>
{atob(item.content)}
</p>
</div>