feat: switch to universal delete function

This commit is contained in:
Xyphyn committed 2023-08-19 13:48:15 -07:00
1 parent 5de92f7ae3
commit 6a4d4077b4
3 files changed
+47 -21

No files matched your search

+27
View File
@@ -59,3 +59,30 @@ export async function save(
}
return save
}
export async function deleteItem(
item: ContentView | Submission,
deleted: boolean,
jwt: string
): Promise<boolean> {
if (isSubmission(item)) item = contentView(item)
if (item.type == 'post') {
return (
await getClient().deletePost({
auth: jwt,
post_id: item.id,
deleted: deleted,
})
).post_view.post.deleted
} else if (item.type == 'comment') {
return (
await getClient().deleteComment({
auth: jwt,
comment_id: item.id,
deleted: deleted,
})
).comment_view.post.deleted
}
return deleted
}