diff --git a/src/app/game/berry-dash/chatroom/page.tsx b/src/app/game/berry-dash/chatroom/page.tsx index fbbed6e..0c48fce 100644 --- a/src/app/game/berry-dash/chatroom/page.tsx +++ b/src/app/game/berry-dash/chatroom/page.tsx @@ -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 () { >

{item.username}

-

+

{ + 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)}