채팅 연속 입력 전부 전송(짧은 연타 허용 + 보내기 대기열), 사람도 '입력 중' 표시, 오른쪽 위 소리 크기(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:
@@ -14,6 +14,7 @@ import { useServerNow } from '../../components/TurnTimer';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
import { ChatMessage, sameRun } from '../../components/ChatMessage';
|
||||
import { useStickToBottom } from '../../lib/useStickToBottom';
|
||||
import { useChatOutbox, useTypingSignal } from '../../lib/chat-input';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
@@ -401,6 +402,8 @@ function ChatBox({ v, players, me, act }: { v: MafiaView; players: Record<string
|
||||
const [text, setText] = useState('');
|
||||
const [seen, setSeen] = useState<Record<string, number>>({});
|
||||
const { ref: listRef, pin } = useStickToBottom<HTMLDivElement>();
|
||||
// Lines typed quickly all go out, one per CHAT_GAP_MS (the game refuses faster ones).
|
||||
const send = useChatOutbox<{ channel: Channel; text: string }>((m) => act({ type: 'chat', ...m }), 750);
|
||||
const cur: Channel = tabs.includes(tab) ? tab : 'day';
|
||||
// Day → 전체; night → the first private channel I may write in (only on my own screen).
|
||||
const phaseKey = `${v.day}-${v.phase.kind}`;
|
||||
@@ -424,6 +427,8 @@ function ChatBox({ v, players, me, act }: { v: MafiaView; players: Record<string
|
||||
useEffect(pin, [cur, pin]);
|
||||
const ch = v.channels.find((c) => c.channel === cur);
|
||||
const canWrite = !!ch?.canWrite;
|
||||
// "입력 중" only from the public 전체 chat (night channels stay secret).
|
||||
const typing = useTypingSignal('game', canWrite && cur === 'day');
|
||||
const why = ch ? ch.why : me ? '이 채팅은 읽기만 할 수 있어요.' : '관전 중에는 채팅을 쓸 수 없어요.';
|
||||
const onTabKey = (e: KeyboardEvent<HTMLDivElement>) => {
|
||||
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
|
||||
@@ -477,15 +482,20 @@ function ChatBox({ v, players, me, act }: { v: MafiaView; players: Record<string
|
||||
e.preventDefault();
|
||||
const t = text.trim();
|
||||
if (!t) return;
|
||||
act({ type: 'chat', channel: cur, text: t.slice(0, 200) });
|
||||
send({ channel: cur, text: t.slice(0, 200) });
|
||||
setText('');
|
||||
typing.stop();
|
||||
pin();
|
||||
}}
|
||||
>
|
||||
<input
|
||||
className="input"
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onChange={(e) => {
|
||||
setText(e.target.value);
|
||||
typing.onText(e.target.value);
|
||||
}}
|
||||
onBlur={typing.stop}
|
||||
maxLength={200}
|
||||
placeholder={`${CHANNEL_KO[cur]} 채팅에 쓰기`}
|
||||
aria-label={`${CHANNEL_KO[cur]} 채팅 메시지`}
|
||||
|
||||
Reference in New Issue
Block a user