mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Allow users to delete their chats when deleting characters
This commit is contained in:
@@ -1,15 +1,26 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
callPopup,
|
||||||
characters, deleteCharacter,
|
characters, deleteCharacter,
|
||||||
event_types,
|
event_types,
|
||||||
eventSource,
|
eventSource,
|
||||||
getCharacters,
|
getCharacters,
|
||||||
getOneCharacter,
|
|
||||||
getRequestHeaders, handleDeleteCharacter, this_chid
|
getRequestHeaders, handleDeleteCharacter, this_chid
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
import {favsToHotswap} from "./RossAscends-mods.js";
|
import {favsToHotswap} from "./RossAscends-mods.js";
|
||||||
|
|
||||||
|
const popupMessage = {
|
||||||
|
deleteChat(characterCount) {
|
||||||
|
return `<h3>Delete ${characterCount} characters?</h3>
|
||||||
|
<b>THIS IS PERMANENT!<br><br>
|
||||||
|
<label for="del_char_checkbox" class="checkbox_label justifyCenter">
|
||||||
|
<input type="checkbox" id="del_char_checkbox" />
|
||||||
|
<span>Also delete the chat files</span>
|
||||||
|
</label><br></b>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const toggleFavoriteHighlight = (characterId) => {
|
const toggleFavoriteHighlight = (characterId) => {
|
||||||
const element = document.getElementById(`CharID${characterId}`);
|
const element = document.getElementById(`CharID${characterId}`);
|
||||||
element.classList.toggle('is_fav');
|
element.classList.toggle('is_fav');
|
||||||
@@ -317,9 +328,16 @@ class CharacterGroupOverlay {
|
|||||||
.then(() => getCharacters())
|
.then(() => getCharacters())
|
||||||
.then(() => this.browseState())
|
.then(() => this.browseState())
|
||||||
|
|
||||||
handleContextMenuDelete = () => Promise.all(this.selectedCharacters.map(async characterId => CharacterContextMenu.delete(characterId)))
|
handleContextMenuDelete = () => {
|
||||||
|
callPopup(
|
||||||
|
popupMessage.deleteChat(this.selectedCharacters.length),
|
||||||
|
null
|
||||||
|
).then(deleteChats =>
|
||||||
|
Promise.all(this.selectedCharacters.map(async characterId => CharacterContextMenu.delete(characterId, deleteChats)))
|
||||||
.then(() => getCharacters())
|
.then(() => getCharacters())
|
||||||
.then(() => this.browseState())
|
.then(() => this.browseState())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
addStateChangeCallback = callback => this.stateChangeCallbacks.push(callback);
|
addStateChangeCallback = callback => this.stateChangeCallbacks.push(callback);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user