mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-25 22:46:31 -04:00
ae201f5299
New: Season packs and multi-episode releases will show as a single item in the queue Closes #6537
26 lines
508 B
TypeScript
26 lines
508 B
TypeScript
import KeysMatching from 'typings/Helpers/KeysMatching';
|
|
|
|
function selectUniqueIds<T, K>(items: T[], idProp: KeysMatching<T, K>) {
|
|
const result = items.reduce((acc: Set<K>, item) => {
|
|
if (!item[idProp]) {
|
|
return acc;
|
|
}
|
|
|
|
const value = item[idProp] as K;
|
|
|
|
if (Array.isArray(value)) {
|
|
value.forEach((v) => {
|
|
acc.add(v);
|
|
});
|
|
} else {
|
|
acc.add(value);
|
|
}
|
|
|
|
return acc;
|
|
}, new Set<K>());
|
|
|
|
return Array.from(result);
|
|
}
|
|
|
|
export default selectUniqueIds;
|