Added delete stash icons and dialog.
This commit is contained in:
@@ -80,6 +80,7 @@ async function signup(credentials) {
|
||||
name: 'Favorites',
|
||||
slug: 'favorites',
|
||||
public: false,
|
||||
deletable: false,
|
||||
});
|
||||
|
||||
return fetchUser(userId);
|
||||
|
||||
@@ -80,6 +80,24 @@ async function updateStash(stashId, newStash, sessionUser) {
|
||||
return curateStash(stash);
|
||||
}
|
||||
|
||||
async function removeStash(stashId, sessionUser) {
|
||||
if (!sessionUser) {
|
||||
throw new HttpError('You are not authenthicated', 401);
|
||||
}
|
||||
|
||||
const removed = await knex('stashes')
|
||||
.where({
|
||||
id: stashId,
|
||||
user_id: sessionUser.id,
|
||||
deletable: true,
|
||||
})
|
||||
.delete();
|
||||
|
||||
if (removed === 0) {
|
||||
throw new HttpError('Unable to remove this stash', 400);
|
||||
}
|
||||
}
|
||||
|
||||
async function stashActor(actorId, stashId, sessionUser) {
|
||||
const stash = await fetchStash(stashId, sessionUser);
|
||||
|
||||
@@ -149,6 +167,7 @@ async function unstashMovie(movieId, stashId, sessionUser) {
|
||||
module.exports = {
|
||||
createStash,
|
||||
curateStash,
|
||||
removeStash,
|
||||
stashActor,
|
||||
stashScene,
|
||||
stashMovie,
|
||||
|
||||
@@ -45,6 +45,7 @@ const {
|
||||
|
||||
const {
|
||||
createStash,
|
||||
removeStash,
|
||||
stashActor,
|
||||
stashScene,
|
||||
stashMovie,
|
||||
@@ -87,6 +88,7 @@ async function initServer() {
|
||||
|
||||
router.post('/api/stashes', createStash);
|
||||
router.patch('/api/stashes/:stashId', updateStash);
|
||||
router.delete('/api/stashes/:stashId', removeStash);
|
||||
|
||||
router.post('/api/stashes/:stashId/actors', stashActor);
|
||||
router.post('/api/stashes/:stashId/scenes', stashScene);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const {
|
||||
createStash,
|
||||
removeStash,
|
||||
stashActor,
|
||||
stashScene,
|
||||
stashMovie,
|
||||
@@ -23,6 +24,12 @@ async function updateStashApi(req, res) {
|
||||
res.send(stash);
|
||||
}
|
||||
|
||||
async function removeStashApi(req, res) {
|
||||
await removeStash(req.params.stashId, req.session.user);
|
||||
|
||||
res.status(204).send();
|
||||
}
|
||||
|
||||
async function stashActorApi(req, res) {
|
||||
await stashActor(req.body.actorId, req.params.stashId, req.session.user);
|
||||
|
||||
@@ -61,6 +68,7 @@ async function unstashMovieApi(req, res) {
|
||||
|
||||
module.exports = {
|
||||
createStash: createStashApi,
|
||||
removeStash: removeStashApi,
|
||||
stashActor: stashActorApi,
|
||||
stashScene: stashSceneApi,
|
||||
stashMovie: stashMovieApi,
|
||||
|
||||
Reference in New Issue
Block a user