fix(ui): extract team models dirty check into a helper

Keeps the dirty-field test under the no-long-condition-chain lint budget.

Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com>
This commit is contained in:
GokayAI 2026-10-23 11:21:51 +01:00
parent f94d352a82
commit 99cc5977d1
No known key found for this signature in database

View file

@ -104,17 +104,22 @@ export function computeTeamModelBadges(
];
}
// react-hook-form reports a dirty array field as `true` or as an array/object of flags.
function isFieldDirty(dirty: unknown): boolean {
if (dirty === true) {
return true;
}
if (dirty === null || typeof dirty !== "object") {
return false;
}
return Object.values(dirty as Record<string, unknown>).some(Boolean);
}
export function modelsFieldForTeamUpdate(
dirtyModels: unknown,
models: string[] | undefined,
): { models: string[] } | Record<string, never> {
const isDirty =
dirtyModels === true ||
(Array.isArray(dirtyModels) && dirtyModels.some(Boolean)) ||
(dirtyModels !== null &&
typeof dirtyModels === "object" &&
Object.values(dirtyModels as Record<string, unknown>).some(Boolean));
if (!isDirty) {
if (!isFieldDirty(dirtyModels)) {
return {};
}
return { models: normalizeTeamModelSelection(models) };