Update combined static Vd and weight-based settings

This commit is contained in:
2026-02-07 10:12:06 +00:00
parent b7a585a223
commit 199872d742
7 changed files with 73 additions and 77 deletions

View File

@@ -52,6 +52,38 @@ export const useAppState = () => {
}
}
}
// Migrate weightBasedVd from old {enabled, bodyWeight} to new standardVd structure
const oldWeightBasedVd = (migratedPkParams.advanced as any).weightBasedVd;
if (oldWeightBasedVd && typeof oldWeightBasedVd === 'object' && 'enabled' in oldWeightBasedVd) {
// Old format detected: {enabled: boolean, bodyWeight: string}
if (oldWeightBasedVd.enabled) {
// Convert to new weight-based preset
migratedPkParams.advanced.standardVd = {
preset: 'weight-based',
customValue: migratedPkParams.advanced.standardVd?.customValue || '377',
bodyWeight: oldWeightBasedVd.bodyWeight || '70'
};
} else {
// Keep existing standardVd, but ensure bodyWeight is present
if (!migratedPkParams.advanced.standardVd?.bodyWeight) {
migratedPkParams.advanced.standardVd = {
...migratedPkParams.advanced.standardVd,
bodyWeight: oldWeightBasedVd.bodyWeight || '70'
};
}
}
// Remove old weightBasedVd property
delete (migratedPkParams.advanced as any).weightBasedVd;
}
// Ensure bodyWeight exists in standardVd (for new installations or old formats)
if (!migratedPkParams.advanced.standardVd?.bodyWeight) {
migratedPkParams.advanced.standardVd = {
...migratedPkParams.advanced.standardVd,
bodyWeight: '70'
};
}
}
// Validate numeric fields and replace empty/invalid values with defaults