Fix being able to see buttons if there is one that you can't see at the top

This commit is contained in:
Wingysam 2018-11-23 10:29:05 -05:00
parent ddbaf05936
commit d2351c6eb5
2 changed files with 3 additions and 1 deletions

View file

@ -34,12 +34,14 @@ module.exports = (db) => {
router.get('/:user', verifyAuth(), async (req, res) => {
try {
const dbUser = await db.get(req.params.user);
const firstCanSee = dbUser.wishlist.findIndex(element => (element.addedBy === req.params.user));
const wishlistReverse = [...dbUser.wishlist].reverse();
const lastCanSeeValue = wishlistReverse.find(element => (element.addedBy === req.params.user));
const lastCanSee = dbUser.wishlist.indexOf(lastCanSeeValue);
res.render('wishlist', {
title: `Wishlist - ${dbUser._id}`,
wishlist: dbUser.wishlist,
firstCanSee,
lastCanSee
});
} catch (error) {