Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/features/rolling-paper/components/rolling-paper-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,15 @@ function RollingPaperList({ cardData, totalPages, currentPage, onTurnCards }) {
const navigate = useNavigate();

const handleCardClick = (cardId) => {
if(!cardId) {
navigate("*");
return;
}

navigate(`/post/${cardId}`);
};


const profileImages = useMemo(
() =>
cardData.flatMap((card) =>
Expand Down
35 changes: 25 additions & 10 deletions src/hooks/use-image-loader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,51 @@ function useImageListLodeChecker(imageList = []) {
useEffect(() => {
if (!imageList.length) return;

let cancelled = false;

setImageLoadStates((prev) => {
const nextStates = { ...prev };
imageList.forEach(({ id }) => {
if (nextStates[id] === undefined) {
nextStates[id] = false;
}
if (nextStates[id] === undefined) nextStates[id] = false;
});
return nextStates;
});

const imageMap = {};

imageList.forEach(({ id, backgroundImageURL }) => {
setImageLoadStates((prev) => {
if (prev[id]) return prev;
if (prev[id] === true) return prev;

if (!backgroundImageURL) {
return { ...prev, [id]: false };
}
if (!backgroundImageURL) return { ...prev, [id]: false };

const img = new Image();
img.src = backgroundImageURL;
imageMap[id] = img;

img.onload = () => {
setImageLoadStates((p) => ({ ...p, [id]: true }));
if (!cancelled) {
setImageLoadStates((p) => ({ ...p, [id]: true }));
}
};

img.onerror = () => {
setImageLoadStates((p) => ({ ...p, [id]: false }));
if (!cancelled) {
setImageLoadStates((p) => ({ ...p, [id]: false }));
}
};

img.src = backgroundImageURL;
return prev;
});
});

return () => {
cancelled = true;
Object.values(imageMap).forEach((img) => {
img.onload = null;
img.onerror = null;
});
};
}, [imageList]);

return imageLoadStates;
Expand Down
24 changes: 10 additions & 14 deletions src/pages/404-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ const ErrorNumber = styled.h1`
font-weight: 900;
color: var(--color-purple-700);
margin: 0;
font-size: 200px;
font-size: 150px;

${media.mobile} {
font-size: 130px;
font-size: 110px;
}
`;

const ErrorComment = styled.span`
font-size: 80px;
font-size: 70px;
color: #6e6293;
font-weight: 700;

em {
font-size: 100px;
font-size: 90px;
font-weight: 800;
font-style: normal;
color: #240079;
Expand All @@ -72,24 +72,20 @@ const ErrorComment = styled.span`
}

${media.mobile} {
font-size: 50px;
font-size: 40px;
em {
font-size: 60px;
font-size: 50px;
}
}
`;

const ErrorCommentSofter = styled.span`
font-size: 50px;
font-size: 25px;
color: #6e6293;
font-weight: 400;

${media.tablet} {
font-size: 40px;
}

${media.mobile} {
font-size: 30px;
font-size: 18px;
}
`;

Expand Down Expand Up @@ -133,10 +129,10 @@ const Error404Page = () => {
<AirplaneSVG src={logoImage} />
<ErrorNumber>404</ErrorNumber>
<ErrorComment>
<em>Oops!</em> Page Not Found...
<em>앗 이런!</em> 페이지를 찾을 수 없습니다.
</ErrorComment>
<ErrorCommentSofter>
Don't worry, let's get you back on track.
페이지의 주소가 올바르지 않거나, 삭제 또는 다른 페이지로 변경되었습니다.
</ErrorCommentSofter>
<HomeButton
size={BUTTON_SIZE.large}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/messages-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,12 @@ function MessagesPage() {
} catch (error) {
// TODO: Error 처리 필요
console.error(error);
navigate("/notfound", { replace: true });
}
}

fetchRollingPaper();
}, [id]);
}, [id, navigate]);

const content = (
<>
Expand Down