사이트: 모르는 유저 다시 받기가 한 번 실패하면 영영 안 받던 문제
받는 중 중복만 막고, 실패하면 다음 이벤트에서 다시 받는다 (성공한 아이디만 기억). lib/unknown-users.ts 로 빼고 테스트 추가, 목 서버에 /mock/users-fail · latejoin?again=1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
24
site/web/src/lib/unknown-users.ts
Normal file
24
site/web/src/lib/unknown-users.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 처음 보는 유저 아이디가 오면 유저 목록을 다시 받아 온다 (v1.4.1 이하 앱은 녹음 중에 들어온 사람을 알려 주지 않아 "알 수 없음"으로 뜸).
|
||||
* - 받는 중에는 또 부르지 않는다
|
||||
* - 받기에 성공한 아이디는 다시 묻지 않는다 (목록에 없어도 매 발화마다 부르지 않게)
|
||||
* - 실패하면 기억하지 않아 다음 이벤트에서 다시 받는다
|
||||
*/
|
||||
export function makeUnknownUserCheck(load: () => Promise<unknown>) {
|
||||
const done = new Set<string>();
|
||||
let busy = false;
|
||||
return (ids: string[], known: (id: string) => boolean): void => {
|
||||
if (busy) return;
|
||||
const fresh = ids.filter((id) => id && !known(id) && !done.has(id));
|
||||
if (!fresh.length) return;
|
||||
busy = true;
|
||||
load()
|
||||
.then(
|
||||
() => fresh.forEach((id) => done.add(id)),
|
||||
() => {},
|
||||
)
|
||||
.finally(() => {
|
||||
busy = false;
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user