Spaces:
Sleeping
Sleeping
File size: 481 Bytes
01b06a3 7bf1507 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import type { Model } from "$lib/types/Model";
export const findCurrentModel = (
models: Model[],
oldModels: { id: string; transferTo?: string }[] = [],
id?: string
): Model => {
if (id) {
const direct = models.find((m) => m.id === id);
if (direct) return direct;
const legacy = oldModels.find((m) => m.id === id);
if (legacy?.transferTo) {
const mapped = models.find((m) => m.id === legacy.transferTo);
if (mapped) return mapped;
}
}
return models[0];
};
|