mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-26 02:24:44 +03:00
delete slate when removed the last file from it
This commit is contained in:
parent
0a5281b29b
commit
44b8e0d9af
@ -62,6 +62,24 @@ export default async (req, res) => {
|
||||
|
||||
Utilities.removeFromSlateCheckCoverImage(slate, fileIds);
|
||||
|
||||
if (fileIds.length >= slate.objects.length) {
|
||||
let updatedSlate = await Data.getSlateById({ id: req.body.data.slateId, includeFiles: true });
|
||||
|
||||
if (!updatedSlate.objects.length) {
|
||||
const deleteResponse = await Data.deleteSlateById({ id: slate.id });
|
||||
|
||||
if (!deleteResponse) {
|
||||
return res.status(404).send({ decorator: "SERVER_DELETE_SLATE_FAILED", error: true });
|
||||
}
|
||||
|
||||
if (deleteResponse.error) {
|
||||
return res.status(500).send({ decorator: "SERVER_DELETE_SLATE_FAILED", error: true });
|
||||
}
|
||||
|
||||
SearchManager.deleteSlate(slate);
|
||||
}
|
||||
}
|
||||
|
||||
ViewerManager.hydratePartial(id, { slates: true });
|
||||
|
||||
return res.status(200).send({
|
||||
|
Loading…
Reference in New Issue
Block a user