CI / Build & Quality Checks (push) Successful in 1m59s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 15s
CI / Trigger Desktop Build (push) Successful in 12s
CI / Playwright smoke (e2e) (push) Successful in 2m23s
On deafen the participant set is snapshotted; on undeafen it is diffed and, only if it changed and you were deafened for at least 10 s, one auto-dismissing toast says 'While you were deafened: Alice, Bob joined · Cole left' (names capped at 3 + N more). Rides the membership stream that already drives the join/leave sounds — no new subscriptions; PTT holds don't touch deafen so they can't trigger it. Verified headless: short deafen → nothing; bob leaves during an 11 s deafen → 'bob left'; long deafen with no change → nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
/**
|
|
* [Gitea #128] "While you were deafened: Alice, Bob joined · Cole left".
|
|
* Pure diff + wording; the hook snapshots the participant set on deafen and
|
|
* calls this on undeafen.
|
|
*/
|
|
export const DEAFEN_CATCHUP_MIN_MS = 10_000;
|
|
const MAX_NAMES = 3;
|
|
|
|
const list = (names: string[]): string => {
|
|
const shown = names.slice(0, MAX_NAMES);
|
|
const more = names.length - shown.length;
|
|
return more > 0 ? `${shown.join(', ')} and ${more} more` : shown.join(', ');
|
|
};
|
|
|
|
export const deafenCatchUpText = (
|
|
before: Set<string>,
|
|
after: Set<string>,
|
|
nameOf: (userId: string) => string,
|
|
): string | null => {
|
|
const joined = Array.from(after).filter((u) => !before.has(u));
|
|
const left = Array.from(before).filter((u) => !after.has(u));
|
|
if (joined.length === 0 && left.length === 0) return null;
|
|
const parts: string[] = [];
|
|
if (joined.length) parts.push(`${list(joined.map(nameOf))} joined`);
|
|
if (left.length) parts.push(`${list(left.map(nameOf))} left`);
|
|
return `While you were deafened: ${parts.join(' · ')}`;
|
|
};
|