goon/mobile/src/lib/lastPlayback.ts
goon-foss 21500837ab
Some checks failed
Backend tests / test (push) Has been cancelled
feat(bugreport): auto-attach device + last-playback context
Playback reports ("doesn't start", "audio lags") came in with no way to know the
device or which source/server was used, forcing a follow-up question. Now the bug
report auto-context also carries:
- device = phone model / Android version (Platform.constants, zero-dep)
- play = last-played origin/host, mode, position, and last player error

New in-memory lastPlayback store written by PlayerScreen on source/status change, read
by BugReportFAB when composing a report. Reset on app restart (current session only).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 21:53:30 +03:00

36 lines
1.2 KiB
TypeScript

/**
* Ostatni kontekst odtwarzania (in-memory, bieżąca sesja apki). PlayerScreen go zapisuje,
* BugReportFAB dokleja do auto-kontekstu zgłoszenia. Dzięki temu playback-bugi ("nie gra",
* "audio się rozjeżdża") od razu niosą: które źródło/serwer, host CDN, pozycję i ostatni
* błąd, bez dopytywania usera. Reset przy restarcie apki (dotyczy tylko ostatniego odtwarzania).
*/
export type LastPlayback = {
origin?: string;
quality?: string;
host?: string;
positionSec?: number;
mode?: string;
error?: string;
};
let _last: LastPlayback = {};
export function setLastPlayback(patch: LastPlayback): void {
_last = { ..._last, ...patch };
}
export function getLastPlayback(): LastPlayback {
return _last;
}
/** Jednolinijkowy opis do doklejenia w bug-report (albo '' gdy nic nie grało). */
export function formatLastPlayback(): string {
const p = _last;
if (!p.origin && !p.host) return '';
const bits = [p.origin || p.host];
if (p.quality) bits.push(p.quality);
if (p.mode) bits.push(p.mode);
if (p.positionSec != null) bits.push(`@${p.positionSec}s`);
if (p.error) bits.push(`err:${p.error.slice(0, 60)}`);
return bits.filter(Boolean).join(' ');
}