채팅 연속 입력 전부 전송(짧은 연타 허용 + 보내기 대기열), 사람도 '입력 중' 표시, 오른쪽 위 소리 크기(0~100, 기본 50)
- 서버 방 채팅: 0.5초 고정 간격 대신 토큰 버킷(4줄 연속, 초당 2줄) — 도배는 여전히 막음 - 웹: useChatOutbox(방 채팅·마피아·라이어 게임)로 빠르게 친 줄도 순서대로 전송 - typing 메시지(방 채팅 / 게임 공개 채팅만, 마피아 밤 채널은 보내지 않음), BotActivity에 사람 표시 - VolumeControl: 사이트 머리글·방 막대 오른쪽 위, 설정 페이지에도 슬라이더 - e2e/chat.e2e.ts: 연타 7줄, 입력 중, 소리 크기 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react';
|
||||
import { CHAT_MAX, EMOTE_LABEL, EMOTES, type PublicUser, type RoomView } from '@bg/shared/lite';
|
||||
import { create } from 'zustand';
|
||||
import { socket, useRoom } from '../net/socket';
|
||||
import { useChatOutbox, useTypingSignal } from '../lib/chat-input';
|
||||
import { useStickToBottom } from '../lib/useStickToBottom';
|
||||
import { BotActivity } from './BotActivity';
|
||||
import { ChatMessage, sameRun } from './ChatMessage';
|
||||
@@ -15,6 +16,8 @@ export function ChatPanel({ room, me, title = true }: { room: RoomView; me: Publ
|
||||
const [text, setText] = useState('');
|
||||
const { ref: listRef, pin } = useStickToBottom<HTMLDivElement>();
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const send = useChatOutbox((t) => socket.send({ t: 'chat', text: t }), 550);
|
||||
const typing = useTypingSignal('room', room.chatEnabled);
|
||||
const lastId = chat.at(-1)?.id ?? 0;
|
||||
useEffect(() => {
|
||||
useChatSeen.setState({ seen: lastId });
|
||||
@@ -49,7 +52,7 @@ export function ChatPanel({ room, me, title = true }: { room: RoomView; me: Publ
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
<BotActivity room={room} only="typing" />
|
||||
<BotActivity room={room} only="typing" ch="room" />
|
||||
<div className="emote-row">
|
||||
{EMOTES.map((id) => (
|
||||
<button key={id} type="button" onClick={() => socket.send({ t: 'emote', id })}>
|
||||
@@ -63,8 +66,9 @@ export function ChatPanel({ room, me, title = true }: { room: RoomView; me: Publ
|
||||
style={{ flexWrap: 'nowrap' }}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
if (text.trim()) socket.send({ t: 'chat', text: text.trim().slice(0, CHAT_MAX) });
|
||||
if (text.trim()) send(text.trim().slice(0, CHAT_MAX));
|
||||
setText('');
|
||||
typing.stop();
|
||||
pin();
|
||||
}}
|
||||
>
|
||||
@@ -73,7 +77,11 @@ export function ChatPanel({ room, me, title = true }: { room: RoomView; me: Publ
|
||||
className="input"
|
||||
style={{ flex: 1, minHeight: 44 }}
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onChange={(e) => {
|
||||
setText(e.target.value);
|
||||
typing.onText(e.target.value);
|
||||
}}
|
||||
onBlur={typing.stop}
|
||||
onKeyDown={(e) => e.key === 'Escape' && (e.currentTarget as HTMLInputElement).blur()}
|
||||
maxLength={CHAT_MAX}
|
||||
placeholder="메시지 입력 (Enter)"
|
||||
|
||||
Reference in New Issue
Block a user