mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-01-11 20:10:20 +00:00
fix first comma when select all episodes
This commit is contained in:
parent
51b4c173ab
commit
3bb33819a7
1 changed files with 13 additions and 5 deletions
|
|
@ -27,17 +27,15 @@ const EpisodeListing: React.FC = () => {
|
||||||
}, [store.episodeListing]);
|
}, [store.episodeListing]);
|
||||||
|
|
||||||
const close = () => {
|
const close = () => {
|
||||||
dispatch({
|
const mergedEpisodes = [...parseEpisodes(store.downloadOptions.e), ...selected];
|
||||||
type: 'episodeListing',
|
|
||||||
payload: []
|
|
||||||
});
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'downloadOptions',
|
type: 'downloadOptions',
|
||||||
payload: {
|
payload: {
|
||||||
...store.downloadOptions,
|
...store.downloadOptions,
|
||||||
e: `${[...new Set([...parseSelect(store.downloadOptions.e), ...selected])].join(',')}`
|
e: serializeEpisodes(mergedEpisodes)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dispatch({ type: 'episodeListing', payload: [] });
|
||||||
};
|
};
|
||||||
|
|
||||||
const getEpisodesForSeason = (season: string | 'all') => {
|
const getEpisodesForSeason = (season: string | 'all') => {
|
||||||
|
|
@ -168,6 +166,16 @@ const EpisodeListing: React.FC = () => {
|
||||||
</Dialog>
|
</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 parseSelect = (s: string): string[] => {
|
||||||
const ret: string[] = [];
|
const ret: string[] = [];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue