fix: failsafe to prevent all convos clearing from delete button

This commit is contained in:
Danny Avila 2023-03-28 11:42:36 -04:00
parent 0fbbe74479
commit 4564b648f7
2 changed files with 8 additions and 2 deletions

View file

@ -41,11 +41,17 @@ router.post('/gen_title', async (req, res) => {
router.post('/clear', async (req, res) => {
let filter = {};
const { conversationId } = req.body.arg;
const { conversationId, source } = req.body.arg;
if (conversationId) {
filter = { conversationId };
}
console.log('source:', source);
if (source === 'button' && !conversationId) {
return res.status(200).send('No conversationId provided');
}
try {
const dbResponse = await deleteConvos(req?.session?.user?.username, filter);
res.status(201).send(dbResponse);

View file

@ -21,7 +21,7 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler,
}
);
const clickHandler = () => trigger({ conversationId });
const clickHandler = () => trigger({ conversationId, source: 'button' });
const handler = renaming ? cancelHandler : clickHandler;
return (