From 52a57e79f57dda57b0f6bc42c5a6f0e60e14261b Mon Sep 17 00:00:00 2001 From: sozy <thinpotatogithub@gmail.com> Date: Sun, 8 Oct 2023 20:25:31 +0700 Subject: [PATCH] fix: bug item_count on create and update watchlist --- src/public/js/components/modal/watchlistAddItem.js | 3 ++- src/server/app/Service/WatchlistService.php | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/public/js/components/modal/watchlistAddItem.js b/src/public/js/components/modal/watchlistAddItem.js index b2e14a9..739714a 100644 --- a/src/public/js/components/modal/watchlistAddItem.js +++ b/src/public/js/components/modal/watchlistAddItem.js @@ -116,7 +116,7 @@ function fetchSearch(replace = false) { e.addEventListener('click', () => { if (!catalogSelected.includes(e.dataset.id)) { - if (catalogSelected.length === MAX_ITEMS) { + if (catalogSelected.length >= MAX_ITEMS) { showToast("Failed", "You can add up to 50 items"); setTimeout(() => { const toast = document.querySelector("#toast"); @@ -163,6 +163,7 @@ function fetchSearch(replace = false) { } function getCatalogSelected() { + catalogSelected = []; const btnDelete = document.querySelectorAll("button.watchlist-item__delete"); btnDelete.forEach(btn => { diff --git a/src/server/app/Service/WatchlistService.php b/src/server/app/Service/WatchlistService.php index 5ccd7f5..0f3a12b 100644 --- a/src/server/app/Service/WatchlistService.php +++ b/src/server/app/Service/WatchlistService.php @@ -55,7 +55,6 @@ class WatchlistService $watchlist->visibility = $watchlistCreateRequest->visibility; $watchlist->category = "DRAMA"; $watchlist->userId = $watchlistCreateRequest->userId; - $watchlist->itemCount = count($watchlistCreateRequest->items); // check watchlist category by travers through items $cntDrama = 0; @@ -121,7 +120,6 @@ class WatchlistService $watchlist->visibility = $watchlistEditRequest->visibility; $watchlist->category = "DRAMA"; $watchlist->userId = $watchlistEditRequest->userId; - $watchlist->itemCount = count($watchlistEditRequest->items); // check watchlist category by travers through items $cntDrama = 0; -- GitLab