1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-25 22:46:31 -04:00
Files
Sonarr/frontend/src/Utilities/Object/selectUniqueIds.ts
T
Mark McDowall ae201f5299 Use react-query for queue UI
New: Season packs and multi-episode releases will show as a single item in the queue
Closes #6537
2025-09-01 15:08:19 -07:00

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;