mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Delete all group chats with a group.
This commit is contained in:
@ -1005,7 +1005,7 @@ function select_group_chats(groupId, skipAnimation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$("#dialogue_popup").data("group_id", groupId);
|
$("#dialogue_popup").data("group_id", groupId);
|
||||||
callPopup("<h3>Delete the group?</h3>", "del_group");
|
callPopup('<h3>Delete the group?</h3><p>This will also delete all your chats with that group. If you want to delete a single conversation, select a "View past chats" option in the lower left menu.</p>', "del_group");
|
||||||
});
|
});
|
||||||
|
|
||||||
updateFavButtonState(group?.fav ?? false);
|
updateFavButtonState(group?.fav ?? false);
|
||||||
|
23
server.js
23
server.js
@ -2181,16 +2181,29 @@ app.post('/deletegroup', jsonParser, async (request, response) => {
|
|||||||
|
|
||||||
const id = request.body.id;
|
const id = request.body.id;
|
||||||
const pathToGroup = path.join(directories.groups, sanitize(`${id}.json`));
|
const pathToGroup = path.join(directories.groups, sanitize(`${id}.json`));
|
||||||
const pathToChat = path.join(directories.groupChats, sanitize(`${id}.jsonl`));
|
|
||||||
|
try {
|
||||||
|
// Delete group chats
|
||||||
|
const group = json5.parse(fs.readFileSync(pathToGroup));
|
||||||
|
|
||||||
|
if (group && Array.isArray(group.chats)) {
|
||||||
|
for (const chat of group.chats) {
|
||||||
|
console.log('Deleting group chat', chat);
|
||||||
|
const pathToFile = path.join(directories.groupChats, `${id}.jsonl`);
|
||||||
|
|
||||||
|
if (fs.existsSync(pathToFile)) {
|
||||||
|
fs.rmSync(pathToFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Could not delete group chats. Clean them up manually.', error);
|
||||||
|
}
|
||||||
|
|
||||||
if (fs.existsSync(pathToGroup)) {
|
if (fs.existsSync(pathToGroup)) {
|
||||||
fs.rmSync(pathToGroup);
|
fs.rmSync(pathToGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(pathToChat)) {
|
|
||||||
fs.rmSync(pathToChat);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.send({ ok: true });
|
return response.send({ ok: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user