refactor scrobbling to use duration instead of progress (#2010)

- add scrobble status debug and indicator
- add force / reset scrobble
This commit is contained in:
jeffvli
2026-05-12 22:04:46 -07:00
parent 4226da94ec
commit ffe59b2c78
7 changed files with 438 additions and 65 deletions
+1
View File
@@ -2,6 +2,7 @@ export * from './app.store';
export * from './auth.store';
export * from './full-screen-player.store';
export * from './player.store';
export * from './scrobble-debug.store';
export * from './scroll.store';
export * from './settings.store';
export * from './timestamp.store';
@@ -0,0 +1,45 @@
import { createWithEqualityFn } from 'zustand/traditional';
import { PlayerStatus } from '/@/shared/types/types';
export type ScrobbleDebugSnapshot = {
eligibilityMet: boolean;
lastListenSampleTimeSec: null | number;
listenedMs: number;
playerStatus: PlayerStatus;
positionSec: number;
songId?: string;
songName?: string;
submitted: boolean;
targetDurationSec: number;
targetPercentage: number;
trackDurationMs: number;
};
const initialSnapshot: ScrobbleDebugSnapshot = {
eligibilityMet: false,
lastListenSampleTimeSec: null,
listenedMs: 0,
playerStatus: PlayerStatus.PAUSED,
positionSec: 0,
songId: undefined,
songName: undefined,
submitted: false,
targetDurationSec: 240,
targetPercentage: 75,
trackDurationMs: 0,
};
type ScrobbleDebugStore = {
snapshot: ScrobbleDebugSnapshot;
};
export const useScrobbleDebugStore = createWithEqualityFn<ScrobbleDebugStore>()(() => ({
snapshot: initialSnapshot,
}));
export const publishScrobbleDebug = (partial: Partial<ScrobbleDebugSnapshot>) => {
useScrobbleDebugStore.setState((state) => ({
snapshot: { ...state.snapshot, ...partial },
}));
};