From d36f1d17b3bb1991a338cbcc1098dc7928b1520f Mon Sep 17 00:00:00 2001 From: Sam Wing Date: Sun, 17 Nov 2019 08:08:53 -0500 Subject: [PATCH] fix bug that has existed since Initial Commit --- routes/wishlist/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routes/wishlist/index.js b/routes/wishlist/index.js index ffa12e9..b565c21 100644 --- a/routes/wishlist/index.js +++ b/routes/wishlist/index.js @@ -43,7 +43,10 @@ module.exports = (db) => { const lastCanSee = dbUser.wishlist.indexOf(lastCanSeeValue); res.render('wishlist', { title: `Wishlist - ${dbUser._id}`, - wishlist: dbUser.wishlist, + wishlist: [ + ...dbUser.wishlist.filter(item => item.addedBy === req.params.user), + ...dbUser.wishlist.filter(item => item.addedBy !== req.params.user) + ], firstCanSee, lastCanSee }); @@ -124,7 +127,7 @@ module.exports = (db) => { router.post('/:user/remove/:itemId', verifyAuth(), async (req, res) => { if (req.user._id !== req.params.user) { req.flash('error', 'Not correct user'); - return res.redirect(`/wishlists/${req.params.user}`); + return res.redirect(`/wishlist/${req.params.user}`); } const doc = await db.get(req.user._id); for (let i = 0; i < doc.wishlist.length; i++) {