parent
6d88a98282
commit
ac806a2933
@ -0,0 +1,42 @@
|
|||||||
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
|
export interface SeriesQueueDetails {
|
||||||
|
count: number;
|
||||||
|
episodesWithFiles: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createSeriesQueueDetailsSelector(
|
||||||
|
seriesId: number,
|
||||||
|
seasonNumber?: number
|
||||||
|
) {
|
||||||
|
return createSelector(
|
||||||
|
(state) => state.queue.details.items,
|
||||||
|
(queueItems) => {
|
||||||
|
return queueItems.reduce(
|
||||||
|
(acc: SeriesQueueDetails, item) => {
|
||||||
|
if (item.seriesId !== seriesId) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seasonNumber != null && item.seasonNumber !== seasonNumber) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
acc.count++;
|
||||||
|
|
||||||
|
if (item.episodeHasFile) {
|
||||||
|
acc.episodesWithFiles++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
count: 0,
|
||||||
|
episodesWithFiles: 0,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createSeriesQueueDetailsSelector;
|
@ -1,6 +1,15 @@
|
|||||||
import { kinds } from 'Helpers/Props';
|
import { kinds } from 'Helpers/Props';
|
||||||
|
|
||||||
function getProgressBarKind(status, monitored, progress) {
|
function getProgressBarKind(
|
||||||
|
status: string,
|
||||||
|
monitored: boolean,
|
||||||
|
progress: number,
|
||||||
|
isDownloading: boolean
|
||||||
|
) {
|
||||||
|
if (isDownloading) {
|
||||||
|
return kinds.PURPLE;
|
||||||
|
}
|
||||||
|
|
||||||
if (progress === 100) {
|
if (progress === 100) {
|
||||||
return status === 'ended' ? kinds.SUCCESS : kinds.PRIMARY;
|
return status === 'ended' ? kinds.SUCCESS : kinds.PRIMARY;
|
||||||
}
|
}
|
Loading…
Reference in new issue