fix first comma when select all episodes

This commit is contained in:
ektatas 2026-01-03 15:28:04 +01:00 committed by GitHub
parent 51b4c173ab
commit 3bb33819a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,17 +27,15 @@ const EpisodeListing: React.FC = () => {
}, [store.episodeListing]);
const close = () => {
dispatch({
type: 'episodeListing',
payload: []
});
const mergedEpisodes = [...parseEpisodes(store.downloadOptions.e), ...selected];
dispatch({
type: 'downloadOptions',
payload: {
...store.downloadOptions,
e: `${[...new Set([...parseSelect(store.downloadOptions.e), ...selected])].join(',')}`
e: serializeEpisodes(mergedEpisodes)
}
});
dispatch({ type: 'episodeListing', payload: [] });
};
const getEpisodesForSeason = (season: string | 'all') => {
@ -168,6 +166,16 @@ const EpisodeListing: React.FC = () => {
</Dialog>
);
};
const parseEpisodes = (e: string): string[] => {
if (!e) return [];
return e
.split(',')
.map((s) => s.trim())
.filter((s) => s.length > 0);
};
const serializeEpisodes = (episodes: string[]): string => {
return [...new Set(episodes)].join(',');
};
const parseSelect = (s: string): string[] => {
const ret: string[] = [];