mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
23f7ba02d6
* feat(player-stats): local listening history tab with heatmap and summaries Record play sessions in library.sqlite when the library index is enabled, add Rust read APIs and Tauri commands for year/day aggregates, and ship the Player stats UI with session clustering, event-driven live refresh, and a notice when some servers are excluded from indexing. * test(player-stats): split play_session repo and expand test coverage Move the repository into play_session/ (completion, cluster, integration tests), add remap/purge/FK coverage in Rust, and cover ingestion gates plus live-refresh hooks on the frontend per spec v0.3. * docs(release): CHANGELOG and credits for player stats (PR #849) * fix(player-stats): satisfy tsc and clippy CI gates Use InternetRadioStation field names in the radio skip test and replace manual month/day range checks with RangeInclusive::contains.
26 lines
856 B
TypeScript
26 lines
856 B
TypeScript
export type PlaySessionRecordedDetail = {
|
|
serverId: string;
|
|
trackId: string;
|
|
startedAtMs: number;
|
|
};
|
|
|
|
const EVENT_NAME = 'psysonic:play-session-recorded';
|
|
|
|
export function emitPlaySessionRecorded(detail: PlaySessionRecordedDetail): void {
|
|
if (typeof window === 'undefined') return;
|
|
window.dispatchEvent(new CustomEvent<PlaySessionRecordedDetail>(EVENT_NAME, { detail }));
|
|
}
|
|
|
|
export function onPlaySessionRecorded(
|
|
listener: (detail: PlaySessionRecordedDetail) => void,
|
|
): () => void {
|
|
if (typeof window === 'undefined') return () => {};
|
|
const wrapped = (evt: Event) => {
|
|
const ce = evt as CustomEvent<PlaySessionRecordedDetail>;
|
|
if (!ce?.detail) return;
|
|
listener(ce.detail);
|
|
};
|
|
window.addEventListener(EVENT_NAME, wrapped as EventListener);
|
|
return () => window.removeEventListener(EVENT_NAME, wrapped as EventListener);
|
|
}
|