Files
SubMiner/src/animeui/episode-marks.ts
T
sudacode 0889910687 feat(anime): filter episodes and mark them watched by hand
- Add a filter box above the episode list for a number, range, or name substring, with a "N of M" counter
- Read watch marks from the immersion tracker stats and show them per episode, with a watched count in the header, refreshed on window focus
- Add a right-click menu to mark one episode or a whole catch-up span (this and everything below) watched/unwatched
- Add setWatched/getWatchState IPC plumbing so a manual mark creates the stats row for an episode that was never played
2026-08-03 02:16:22 -07:00

22 lines
946 B
TypeScript

/**
* Which episodes a manual watch mark applies to.
*
* Sources list newest first, so "everything below" the row you right-clicked is
* the back catalogue: the natural shape of "I have watched up to here". The
* span is taken from the full list rather than from what the filter leaves,
* because a filter narrows what you are looking at, not what you have watched.
*/
export type MarkScope = 'one' | 'below';
export function episodesInScope<T>(episodes: T[], index: number, scope: MarkScope): T[] {
if (index < 0 || index >= episodes.length) return [];
return scope === 'one' ? [episodes[index]!] : episodes.slice(index);
}
/** "3 episodes" / "1 episode", for the status line after a bulk mark. */
export function describeMarkCount(count: number, watched: boolean): string {
const noun = count === 1 ? 'episode' : 'episodes';
return watched ? `Marked ${count} ${noun} watched` : `Cleared the watch mark on ${count} ${noun}`;
}