mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-20 00:38:38 +02:00
fix(ams): surface active K-profile when no slot preset is resolvable (#1689 follow-up)
Configure Slot dropped to "default 0.020" on reopen for slots that were physically loaded but unconfigured (tray_type="", no slot_preset_mappings row). The #1689 cali_idx safety net was unreachable from that path — matchingKProfiles early-returned [] on !selectedPresetInfo before the safety net ran. Split the early return so the cali_idx fallback survives the no-preset case: when selectedPresetInfo is null but slotInfo.caliIdx > 0, return the active profile as a single-item list (extruder-matched when known). Strictly additive; caliIdx == 0/null still returns [], existing matcher unchanged when a preset is resolvable.
This commit is contained in:
@@ -748,7 +748,24 @@ export function ConfigureAmsSlotModal({
|
||||
}, [colorCatalog, selectedPresetInfo]);
|
||||
|
||||
const matchingKProfiles = useMemo(() => {
|
||||
if (!kprofilesData?.profiles || !selectedPresetInfo) return [];
|
||||
if (!kprofilesData?.profiles) return [];
|
||||
if (!selectedPresetInfo) {
|
||||
// Assigned-but-unconfigured slot (filament loaded but the printer hasn't
|
||||
// bound a preset yet: tray_type=""/tray_info_idx=""/no slot_preset_mappings
|
||||
// row). The cali_idx safety net further down lives past the main name+id
|
||||
// matcher and never runs from here, so surface the slot's currently-active
|
||||
// K-profile directly so Configure Slot keeps showing it across reopen
|
||||
// instead of dropping to default 0.020 (#1689 follow-up).
|
||||
const activeIdx = slotInfo.caliIdx;
|
||||
if (activeIdx != null && activeIdx > 0) {
|
||||
const active = kprofilesData.profiles.find(
|
||||
p => p.slot_id === activeIdx
|
||||
&& (slotInfo.extruderId === undefined || p.extruder_id === slotInfo.extruderId),
|
||||
);
|
||||
if (active) return [active];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
const { fullName, material, brand, filamentId } = selectedPresetInfo;
|
||||
const upperFullName = fullName.toUpperCase();
|
||||
|
||||
Reference in New Issue
Block a user