From a8f111995f1e6c69ba7692ae2d277933a6170b45 Mon Sep 17 00:00:00 2001 From: primakov Date: Fri, 3 Nov 2023 15:15:47 +0300 Subject: [PATCH] fix likes --- src/routes/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routes/index.ts b/src/routes/index.ts index 57d6495..90ac5f7 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -34,7 +34,12 @@ router.post('/toggle-like', (req, res) => { if (charLikes[charId]) { const currentLikes = new Set(charLikes[charId].likes) - currentLikes.add(id) + + if (currentLikes.has(id)) { + currentLikes.delete(id) + } else { + currentLikes.add(id) + } charLikes[charId].likes = [...currentLikes] } else {