Skip to content

Commit

Permalink
Merge pull request #100 from maeng17/Feature/Like2
Browse files Browse the repository at this point in the history
✨Feat: pull받은 후 ikeArticle 쿼리 최적화 재적용
  • Loading branch information
Jbiscode authored Jun 25, 2024
2 parents 1a32850 + 7f6f2d9 commit 2188dfc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pages/search/IndexPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import FilterComponent from "@components/search/FilterComponent.jsx";
import HeaderComponent from "@components/search/HeaderComponent.jsx";
import SearchArticleComponent from "@components/search/SearchArticleComponent.jsx";
import BasicLayout from "@layouts/BasicLayout.jsx";
import useAuthStore from "@zustand/authStore";


function IndexPage() {
const {id} = useAuthStore();

const location = useLocation();
const query1 = new URLSearchParams(location.search).get('content');
const query2 = new URLSearchParams(location.search).get('category');
Expand Down Expand Up @@ -98,6 +101,9 @@ function IndexPage() {
if (tradeStatus == 'ON_SALE') {
params.push(`tradeStatus=${tradeStatus}`);
}
if (id) {
params.push(`id=${id}`);
}
params.push(`page=${reset? paging: page}`);
params.push(`size=10`);

Expand All @@ -114,6 +120,7 @@ function IndexPage() {
if (Array.isArray(data.searchResult)) {
setArticleDTO(prev => reset ? data.searchResult : [...prev, ...data.searchResult]);
setLikeArticle(data.likeResult);
console.log('likeArticle:', data.likeResult);

setHasMore(data.searchResult.length === 10);

Expand All @@ -133,7 +140,7 @@ function IndexPage() {
useEffect(() => {
setPage(1);
fetchArticles(true);
}, [content, orderBy, category, tradeMethod, tradeStatus]);
}, [content, orderBy, category, tradeMethod, tradeStatus, id]);

useEffect(() => {
if (page > 1) fetchArticles();
Expand Down

0 comments on commit 2188dfc

Please sign in to comment.