1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-22 22:16:13 -04:00

Convert Utilities to TypeScript

This commit is contained in:
Mark McDowall
2024-07-23 15:52:44 -07:00
committed by Mark McDowall
parent 76650af9fd
commit d46f4b2154
85 changed files with 614 additions and 412 deletions
@@ -0,0 +1,27 @@
import ModelBase from 'App/ModelBase';
function getToggledRange<T extends ModelBase>(
items: T[],
id: number,
lastToggled: number
) {
const lastToggledIndex = items.findIndex((item) => item.id === lastToggled);
const changedIndex = items.findIndex((item) => item.id === id);
let lower = 0;
let upper = 0;
if (lastToggledIndex > changedIndex) {
lower = changedIndex;
upper = lastToggledIndex + 1;
} else {
lower = lastToggledIndex;
upper = changedIndex;
}
return {
lower,
upper,
};
}
export default getToggledRange;