fix: collapsible space toggle issue

This commit is contained in:
Timothy J. Baek
2024-10-16 22:36:44 -07:00
parent 7b97d7a718
commit 29c39d44e1
4 changed files with 76 additions and 17 deletions

View File

@@ -215,7 +215,18 @@ async def delete_folder_by_id(id: str, user=Depends(get_verified_user)):
if folder:
try:
result = Folders.delete_folder_by_id_and_user_id(id, user.id)
return result
if result:
# Delete all chats in the folder
chats = Chats.get_chats_by_folder_id_and_user_id(id, user.id)
for chat in chats:
Chats.delete_chat_by_id(chat.id, user.id)
return result
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=ERROR_MESSAGES.DEFAULT("Error deleting folder"),
)
except Exception as e:
log.exception(e)
log.error(f"Error deleting folder: {id}")