Preset Regex: event change (#4616) * feat: PRESET_RENAMED event * fix: emit PRESET_DELETED only when the deletion successes --------- Co-authored-by: ZoinkCN <zoinkcn@outlook.com>
Signed| @@ -87,6 +87,7 @@ export const event_types = { | ||
| 87 | 87 | SECRET_EDITED: 'secret_edited', |
| 88 | 88 | PRESET_CHANGED: 'preset_changed', |
| 89 | 89 | PRESET_DELETED: 'preset_deleted', |
| 90 | + PRESET_RENAMED: 'preset_renamed', | |
| 90 | 91 | MAIN_API_CHANGED: 'main_api_changed', |
| 91 | 92 | WORLDINFO_ENTRIES_LOADED: 'worldinfo_entries_loaded', |
| 92 | 93 | }; |
| @@ -1035,8 +1035,7 @@ export async function initPresetManager() { | ||
| 1035 | 1035 | |
| 1036 | 1036 | await presetManager.renamePreset(newName); |
| 1037 | 1037 | |
| 1038 | 1038 | await eventSource.emit(event_types.PRESET_DELETEDPRESET_RENAMED, { apiId: apiId, nameoldName: oldName, newName: newName }); |
| 1039 | - await eventSource.emit(event_types.PRESET_CHANGED, { apiId: apiId, name: newName }); | |
| 1040 | 1039 | |
| 1041 | 1040 | if (apiId === 'openai') { |
| 1042 | 1041 | // This is a horrible mess, but prevents the renamed preset from being corrupted. |
| @@ -1116,13 +1115,13 @@ export async function initPresetManager() { | ||
| 1116 | 1115 | if (result) { |
| 1117 | 1116 | const successToast = !presetManager.isAdvancedFormatting() ? t`Preset deleted` : t`Template deleted`; |
| 1118 | 1117 | toastr.success(successToast); |
| 1118 | + await eventSource.emit(event_types.PRESET_DELETED, { apiId, name }); | |
| 1119 | 1119 | } else { |
| 1120 | 1120 | const warningToast = !presetManager.isAdvancedFormatting() ? t`Preset was not deleted from server` : t`Template was not deleted from server`; |
| 1121 | 1121 | toastr.warning(warningToast); |
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | saveSettingsDebounced(); |
| 1125 | - await eventSource.emit(event_types.PRESET_DELETED, { apiId: apiId, name: name }); | |
| 1126 | 1125 | }); |
| 1127 | 1126 | |
| 1128 | 1127 | $(document).on('click', '[data-preset-manager-restore]', async function () { |