fix(presets): defer association changes until Save & Apply

- Add isAssociatedWithCurrentPreset() helper to check if entity is associated with the CURRENT preset (not just any preset)
- Fix checkbox to correctly reflect association with currently selected preset
- Introduce tempAssociation state to track pending association changes
- Only save association changes when clicking Save & Apply, not on preset switch
- Discard pending association changes when clicking X/Cancel
- Auto-update association when switching presets if checkbox was checked
- Improve toast messages to clarify when changes will be applied

Fixes issue where checkbox showed incorrect state and association was saved immediately without waiting for Save & Apply.
This commit is contained in:
tomt610
2026-01-11 14:58:17 +00:00
parent d5d649f122
commit bc4f50a82f
2 changed files with 82 additions and 6 deletions
+11
View File
@@ -915,6 +915,17 @@ export function hasPresetAssociation() {
return entityKey && extensionSettings.presetManager.characterAssociations[entityKey] !== undefined;
}
/**
* Checks if the current character/group is associated with the currently active preset
* @returns {boolean} True if the current entity is associated with the active preset
*/
export function isAssociatedWithCurrentPreset() {
const entityKey = getCurrentEntityKey();
const activePresetId = extensionSettings.presetManager?.activePresetId;
if (!entityKey || !activePresetId) return false;
return extensionSettings.presetManager.characterAssociations[entityKey] === activePresetId;
}
/**
* Auto-switches to the preset associated with the current character/group
* Called when character changes. Falls back to default preset if no association.