v1.4.2: 녹음 중에 들어온 사람이 사이트에서 "알 수 없음"으로 뜨던 문제
- 앱: 녹음 중 새로 들어온 사람을 저장한 뒤 users.updated 를 보낸다 - 사이트: 실시간 발화 · 녹음 상태에 모르는 유저 아이디가 오면 유저 목록을 한 번 다시 받는다 (예전 앱 대비) - 목 서버: /mock/latejoin 로 재현 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
// GET /mock/device?registered=0|1 등록 안 된 상태 흉내
|
||||
// GET /mock/live?on=0|1 주기적 가짜 실시간 발화 켜기/끄기
|
||||
// GET /mock/emit 가짜 실시간 발화 하나 즉시 만들기
|
||||
// GET /mock/latejoin 녹음 중에 새 사람이 들어와 말함 (v1.4.1 이하 앱처럼 users.updated 없이 발화만 보냄)
|
||||
// GET /auth/discord?as=notmember 길드 멤버가 아닌 계정으로 로그인 흉내 (403 not_member)
|
||||
import http from 'node:http';
|
||||
import fs from 'node:fs';
|
||||
@@ -166,6 +167,14 @@ async function handle(req, res) {
|
||||
return json(res, 200, { live: state.live });
|
||||
}
|
||||
if (p === '/mock/emit') return json(res, 200, emitLive() ?? { error: 'device_offline' });
|
||||
if (p === '/mock/latejoin') {
|
||||
const n = db.users.length;
|
||||
const u = { id: `41000000000000${String(n).padStart(4, '0')}`, name: `늦게온사람${n}`, color: '#d4537e', avatar: null, excluded: false, riot: [] };
|
||||
db.users.push(u);
|
||||
const it = db.addLiveUtterance(u, '나 지금 들어왔어');
|
||||
broadcast({ type: 'utterance.created', data: it });
|
||||
return json(res, 200, { user: u, utterance: it.id });
|
||||
}
|
||||
|
||||
// 게임 이미지 (목: docs/report/mock/assets)
|
||||
if (p.startsWith('/game-assets/mock/')) {
|
||||
|
||||
@@ -139,21 +139,36 @@ export function DataProvider({ children }: { children: ReactNode }) {
|
||||
alive = false;
|
||||
};
|
||||
}, [epoch, locked]);
|
||||
const reloadUsers = useCallback(() => {
|
||||
api
|
||||
.users()
|
||||
.then((users) => setOverview((o) => (o ? { ...o, users } : o)))
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
const users = overview?.users ?? [];
|
||||
const map = useMemo(() => new Map(users.map((u) => [u.id, u])), [users]);
|
||||
// 처음 보는 사람 아이디는 한 번만 유저 목록을 다시 받아 온다 (v1.4.1 이하 앱은 녹음 중에 들어온 사람을 알려 주지 않아 "알 수 없음"으로 뜸)
|
||||
const asked = useRef(new Set<string>());
|
||||
const checkUnknown = (ids: string[]) => {
|
||||
if (!overview) return;
|
||||
const fresh = ids.filter((id) => id && !map.has(id) && !asked.current.has(id));
|
||||
if (!fresh.length) return;
|
||||
fresh.forEach((id) => asked.current.add(id));
|
||||
reloadUsers();
|
||||
};
|
||||
useLive((e) => {
|
||||
if (e.type === 'users.updated') {
|
||||
// v1.3.5 이하 앱은 빈 목록을 보낸다: 그대로 쓰면 모든 발화가 "알 수 없음"이 되니 다시 받아 온다
|
||||
if (e.data.length) setOverview((o) => (o ? { ...o, users: e.data } : o));
|
||||
else
|
||||
api
|
||||
.users()
|
||||
.then((users) => setOverview((o) => (o ? { ...o, users } : o)))
|
||||
.catch(() => {});
|
||||
else reloadUsers();
|
||||
}
|
||||
if (e.type === 'recording.state') setOverview((o) => (o ? { ...o, recording: e.data } : o));
|
||||
if (e.type === 'recording.state') {
|
||||
setOverview((o) => (o ? { ...o, recording: e.data } : o));
|
||||
checkUnknown(e.data.participants);
|
||||
}
|
||||
if (e.type === 'utterance.created' || e.type === 'utterance.updated') checkUnknown([e.data.userId]);
|
||||
if (e.type === 'games.state') setOverview((o) => (o ? { ...o, live: e.data } : o));
|
||||
});
|
||||
const users = overview?.users ?? [];
|
||||
const map = useMemo(() => new Map(users.map((u) => [u.id, u])), [users]);
|
||||
const userById = useCallback((id: string | undefined | null) => (id ? map.get(id) : undefined), [map]);
|
||||
return <DataCtx.Provider value={{ overview, users, userById }}>{children}</DataCtx.Provider>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user