mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Update prompt manager active character on character edit.
This commit is contained in:
@ -262,6 +262,7 @@ export const event_types = {
|
|||||||
OAI_BEFORE_CHATCOMPLETION: 'oai_before_chatcompletion',
|
OAI_BEFORE_CHATCOMPLETION: 'oai_before_chatcompletion',
|
||||||
OAI_PRESET_CHANGED: 'oai_preset_changed',
|
OAI_PRESET_CHANGED: 'oai_preset_changed',
|
||||||
WORLDINFO_SETTINGS_UPDATED: 'worldinfo_settings_updated',
|
WORLDINFO_SETTINGS_UPDATED: 'worldinfo_settings_updated',
|
||||||
|
CHARACTER_EDITED: 'character_edited',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const eventSource = new EventEmitter();
|
export const eventSource = new EventEmitter();
|
||||||
@ -6523,6 +6524,7 @@ async function createOrEditCharacter(e) {
|
|||||||
);
|
);
|
||||||
$("#create_button").attr("value", "Save");
|
$("#create_button").attr("value", "Save");
|
||||||
crop_data = undefined;
|
crop_data = undefined;
|
||||||
|
eventSource.emit(event_types.CHARACTER_EDITED, {detail: {id: this_chid, character: characters[this_chid]}});
|
||||||
},
|
},
|
||||||
error: function (jqXHR, exception) {
|
error: function (jqXHR, exception) {
|
||||||
$("#create_button").removeAttr("disabled");
|
$("#create_button").removeAttr("disabled");
|
||||||
|
@ -356,6 +356,11 @@ PromptManagerModule.prototype.init = function (moduleConfiguration, serviceSetti
|
|||||||
this.saveServiceSettings().then(() => this.render());
|
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.
|
// Re-render when the group changes.
|
||||||
eventSource.on('groupSelected', (event) => {
|
eventSource.on('groupSelected', (event) => {
|
||||||
this.handleGroupSelected(event)
|
this.handleGroupSelected(event)
|
||||||
@ -641,6 +646,12 @@ PromptManagerModule.prototype.handleCharacterSelected = function (event) {
|
|||||||
if (0 === promptList.length) this.addPromptListForCharacter(this.activeCharacter, openAiDefaultPromptList);
|
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) {
|
PromptManagerModule.prototype.handleGroupSelected = function (event) {
|
||||||
const characterDummy = {id: event.detail.id, group: event.detail.group};
|
const characterDummy = {id: event.detail.id, group: event.detail.group};
|
||||||
this.activeCharacter = characterDummy;
|
this.activeCharacter = characterDummy;
|
||||||
|
Reference in New Issue
Block a user