Update prompt manager active character on character edit.

This commit is contained in:
maver
2023-07-07 22:45:53 +02:00
parent 74a7aa513b
commit 4974c81d4c
2 changed files with 13 additions and 0 deletions

View File

@ -262,6 +262,7 @@ export const event_types = {
OAI_BEFORE_CHATCOMPLETION: 'oai_before_chatcompletion',
OAI_PRESET_CHANGED: 'oai_preset_changed',
WORLDINFO_SETTINGS_UPDATED: 'worldinfo_settings_updated',
CHARACTER_EDITED: 'character_edited',
}
export const eventSource = new EventEmitter();
@ -6523,6 +6524,7 @@ async function createOrEditCharacter(e) {
);
$("#create_button").attr("value", "Save");
crop_data = undefined;
eventSource.emit(event_types.CHARACTER_EDITED, {detail: {id: this_chid, character: characters[this_chid]}});
},
error: function (jqXHR, exception) {
$("#create_button").removeAttr("disabled");

View File

@ -356,6 +356,11 @@ PromptManagerModule.prototype.init = function (moduleConfiguration, serviceSetti
this.saveServiceSettings().then(() => this.render());
});
eventSource.on(event_types.CHARACTER_EDITED, (event) => {
this.handleCharacterUpdated(event);
this.saveServiceSettings().then(() => this.render());
})
// Re-render when the group changes.
eventSource.on('groupSelected', (event) => {
this.handleGroupSelected(event)
@ -641,6 +646,12 @@ PromptManagerModule.prototype.handleCharacterSelected = function (event) {
if (0 === promptList.length) this.addPromptListForCharacter(this.activeCharacter, openAiDefaultPromptList);
}
PromptManagerModule.prototype.handleCharacterUpdated = function (event) {
console.log(event)
this.activeCharacter = {id: event.detail.id, ...event.detail.character};
console.log(this.activeCharacter);
}
PromptManagerModule.prototype.handleGroupSelected = function (event) {
const characterDummy = {id: event.detail.id, group: event.detail.group};
this.activeCharacter = characterDummy;