From 196c9d875ff21ccb8dba800926a65f38253fc459 Mon Sep 17 00:00:00 2001
From: Rykkel <220993G@mymail.nyp.edu.sg>
Date: Sat, 10 Aug 2024 13:32:44 +0800
Subject: [PATCH] Compressed img & fixed img in postpage
---
client/src/pages/CommunityPage.tsx | 3 +--
client/src/pages/PostPage.tsx | 13 +++++++++++--
server/routes/post.js | 27 ++++++++++++++++++++++-----
3 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/client/src/pages/CommunityPage.tsx b/client/src/pages/CommunityPage.tsx
index 51660bf..278175c 100644
--- a/client/src/pages/CommunityPage.tsx
+++ b/client/src/pages/CommunityPage.tsx
@@ -261,8 +261,7 @@ export default function CommunityPage() {
handleImageError(post.id)}
- />
+ onError={() => handleImageError(post.id)} />
)}
diff --git a/client/src/pages/PostPage.tsx b/client/src/pages/PostPage.tsx
index 22af39a..e3c8ceb 100644
--- a/client/src/pages/PostPage.tsx
+++ b/client/src/pages/PostPage.tsx
@@ -54,10 +54,18 @@ const PostPage: React.FC = () => {
useEffect(() => {
if (id) {
+ console.log("useEffect for fetching post called, id:", id);
instance.get(`${config.serverAddress}/post/${id}`)
- .then((res) => setPost(res.data))
+ .then((res) => {
+ setPost(res.data);
+ console.log("Post fetch successfully");
+ })
.catch((error) => console.error("Error fetching post:", error));
}
+ }, [id]);
+
+ useEffect(() => {
+ console.log("PostPage component mounted");
}, []);
useEffect(() => {
@@ -189,7 +197,8 @@ const PostPage: React.FC = () => {
{!imageErrorFlags[post.id] && post.postImage && post.postImage !== null && (