This commit is contained in:
Timothy J. Baek 2024-10-17 18:42:36 -07:00
parent 7ffa3cb022
commit 6e4820cad8
3 changed files with 18 additions and 5 deletions

View File

@ -230,7 +230,9 @@ class FolderTable:
user_id, folder_child.id
)
delete_children(folder_child)
db.delete(folder_child)
folder = db.query(Folder).filter_by(id=folder_child.id).first()
db.delete(folder)
db.commit()
delete_children(folder)

View File

@ -236,10 +236,7 @@ async def delete_folder_by_id(id: str, user=Depends(get_verified_user)):
if result:
return result
else:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=ERROR_MESSAGES.DEFAULT("Error deleting folder"),
)
raise Exception("Error deleting folder")
except Exception as e:
log.exception(e)
log.error(f"Error deleting folder: {id}")

View File

@ -1,5 +1,7 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import { v4 as uuidv4 } from 'uuid';
import { goto } from '$app/navigation';
import {
user,
@ -125,6 +127,18 @@
name = `${name} ${i}`;
}
// Add a dummy folder to the list to show the user that the folder is being created
const tempId = uuidv4();
folders = {
...folders,
tempId: {
id: tempId,
name: name,
created_at: Date.now(),
updated_at: Date.now()
}
};
const res = await createNewFolder(localStorage.token, name).catch((error) => {
toast.error(error);
return null;