Skip to content

Commit

Permalink
fix : 지도 편지 상세보기 로딩 시간 단축 (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmjjaa authored Dec 23, 2024
1 parent 27d89a4 commit 48ff44c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import clsx from 'clsx';
import { DeleteButton } from '../../Delete/DeleteButton';
import { TextArea } from '@/components/Common/TextArea/TextArea';
import { useGetMapReplyList } from '@/hooks/useGetMapReplyList';
// import { ReplyList } from '../../ReplyList/ReplyList';
import { ReplyList } from '../../ReplyList/ReplyList';
import { ReportButton } from '../../Report/ReportButton';
import { useLocation } from 'react-router-dom';
import { Label } from '@/components/Common/BottleLetter/Label/Label';
Expand Down Expand Up @@ -35,28 +35,14 @@ export const MapLetterArchieveDetail = ({
const { pathname } = useLocation();
const letterType = pathname.split('/')[2];
const receivedType = pathname.split('/')[3];
const {
data: mapReplyListData,
isLoading: isMapReplyListDataLoading,
error: mapReplyListDataError
} = useGetMapReplyList({
letterId: Number(letterId) || 0,
page: 1,
size: 9
});
const { data: mapReplyListData, isLoading: isMapReplyListDataLoading } =
useGetMapReplyList({
letterId: Number(letterId) || 0,
page: 1,
size: 9
});

console.log(mapReplyListData);
if (isMapReplyListDataLoading) {
return (
<div className="flex flex-1 w-full h-full">
<Loading />
</div>
);
}

if (mapReplyListDataError instanceof Error) {
return <div>오류...: {mapReplyListDataError.message}</div>;
}
const replyList = mapReplyListData?.content || [];

return (
<div className={clsx(font ? font : 'font-sans')}>
Expand Down Expand Up @@ -95,14 +81,12 @@ export const MapLetterArchieveDetail = ({
</span>
<span>{DayCounter({ createdAt })}</span>
</div>
{/* {mapReplyListData?.content ? (
<div className="mt-16 mx-auto">
<ReplyList
title={title}
keywordReplyListData={mapReplyListData.content}
/>
</div>
) : null} */}

{isMapReplyListDataLoading ? (
<Loading />
) : (
<ReplyList title={title} keywordReplyListData={replyList} />
)}
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useGetMapReplyList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const useGetMapReplyList = ({
page,
size
});
return response.result || { content: [] };
return response.result;
},
enabled: !!letterId
});
Expand Down

0 comments on commit 48ff44c

Please sign in to comment.