One line in the existing toast style when a call you were in ends: the duration from our own join clock, plus the fork's io.lotus.call_summary readout (fork ≥ 0.25.0-lotus.10) when it arrives — "connection was good", "3 reconnects", "connection was poor for 4 min". Nothing is stored or sent; the summary is one postMessage at hangup. Without the fork summary the toast still shows the duration. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
import type { LotusCallSummary } from '../plugins/call/CallEmbed';
|
|
|
|
/** "41 min", "1 h 05 min", "40 s". */
|
|
export const describeCallDuration = (ms: number): string => {
|
|
const s = Math.round(ms / 1000);
|
|
if (s < 60) return `${s} s`;
|
|
const m = Math.round(s / 60);
|
|
if (m < 60) return `${m} min`;
|
|
const h = Math.floor(m / 60);
|
|
return `${h} h ${String(m % 60).padStart(2, '0')} min`;
|
|
};
|
|
|
|
/**
|
|
* [Gitea #143] One line for the call-ended toast: duration (cinny's own
|
|
* clock) plus the fork's verdict when it arrived in time.
|
|
* "Call ended · 41 min · connection was good"
|
|
* "Call ended · 41 min · 3 reconnects"
|
|
* "Call ended · 12 min · connection was poor for 4 min"
|
|
*/
|
|
export function describeCallEnd(durationMs: number, summary?: LotusCallSummary): string {
|
|
const parts = ['Call ended', describeCallDuration(durationMs)];
|
|
if (summary) {
|
|
if (summary.verdict === 'good') parts.push('connection was good');
|
|
else if (summary.verdict === 'fair' || summary.verdict === 'poor') {
|
|
const bits: string[] = [];
|
|
if (summary.reconnects > 0)
|
|
bits.push(`${summary.reconnects} reconnect${summary.reconnects === 1 ? '' : 's'}`);
|
|
if (summary.poorMs >= 5_000)
|
|
bits.push(`connection was poor for ${describeCallDuration(summary.poorMs)}`);
|
|
parts.push(bits.length ? bits.join(', ') : `connection was ${summary.verdict}`);
|
|
}
|
|
}
|
|
return parts.join(' · ');
|
|
}
|