Skip to content

Commit

Permalink
Merge pull request #106 from jennydo/bug-nf
Browse files Browse the repository at this point in the history
fix newsfeed bug
  • Loading branch information
gsthanhnguyen authored Jul 5, 2024
2 parents 07bb1f7 + 7eb6a60 commit e7f6936
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/NewsFeed/Posts/NormalPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { FaHeart, FaComment, FaRegHeart } from "react-icons/fa";
import backBackgroundImage from "../../../assets/images/back-background.jpg";
import "./NormalPost.scss";
import Comment from "./Comment";
import { useAvatarContext } from "../../../hooks/useAvatarContext";

const NormalPost = ({ post }) => {
const { user } = useAuthContext();
Expand All @@ -44,7 +45,15 @@ const NormalPost = ({ post }) => {
const [isFlipped, setIsFlipped] = useState(false);
const handleFlip = () => setIsFlipped(!isFlipped);

const { avatar, username, avatarData } = post.userId;
var avatar = useAvatarContext().avatar;
var avatarData = useAvatarContext().avatarData;
if (post.userId._id !== user.user._id) {
avatar = post.userId.avatar;
avatarData = post.userId.avatarData;
}

const { username } = post.userId;

const stampBackgroundColor = "#" + avatarData.backgroundColor[0];

const previewNum = 12;
Expand Down Expand Up @@ -169,7 +178,7 @@ const NormalPost = ({ post }) => {
<Center className="flipper">
<Grid
className="front"
gridTemplateRows={"30% 10% 1fr 10%"}
gridTemplateRows={"40% 10% 1fr 10%"}
w="100%"
// h="100%"
maxH={"100%"}
Expand Down Expand Up @@ -200,15 +209,15 @@ const NormalPost = ({ post }) => {
zIndex={1}
ml="-65px"
>
<Box w="75%" h="95%" bg={stampBackgroundColor} ml="7px" pt={3}>
<Box w="75%" h="95%" bg={stampBackgroundColor} ml="5px" pt={2}>
<Image src={avatar} />
</Box>
</Box>
</Flex>
</GridItem>

<GridItem w="100%" h="100%" onClick={handleFlip}>
<Heading>{title}</Heading>
<Heading position="relative" zIndex={3}>{title}</Heading>
</GridItem>

<GridItem w="100%" h="100%" onClick={handleFlip}>
Expand Down

0 comments on commit e7f6936

Please sign in to comment.