Skip to content

Commit

Permalink
Merge pull request #19 from chimobi-justice/invalidate-threads-articles
Browse files Browse the repository at this point in the history
invalidate public thread and articles on like and dislike
  • Loading branch information
chimobi-justice authored Sep 26, 2024
2 parents 7a57aa0 + fe0c904 commit 429f79e
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 55 deletions.
109 changes: 57 additions & 52 deletions src/components/ArticleCard/Articles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,66 +71,71 @@ const ArticlesCard: FunctionComponent<IProps> = ({
justifyContent={"space-between"}
>
<Box>
<Heading
size="lg"
lineHeight={"1.6em"}
fontSize={"24px"}
mb={"10px"}
_hover={{
textDecoration: "underline"
}}
>
<Link to={CTA}>
{truncate(title, 80)}
</Link>
</Heading>
<Text
fontSize={"14px"}
lineHeight={"1.7em"}
color={"#0009"}
dangerouslySetInnerHTML={stripTags(truncate(description, 200))}
/>
<Box display={"flex"}>
<Heading
size="lg"
lineHeight={"1.6em"}
fontSize={"24px"}
mb={"10px"}
_hover={{
textDecoration: "underline"
}}
>
<Link to={CTA}>
{truncate(title, 80)}
</Link>
</Heading>

<Flex flex="1" gap={2} my={"12px"} flexDirection={{ base: "column", md: "row" }}>
<Box display={"flex"} gap={3} alignItems={"center"}>
{authorUsername && (
<Link to={`/user/${authorUsername}`}>
<Avatar size={"xs"} name={authorFullname} src={authorAvatar} />
{isOwner && (
<Flex p={"5px"} gap={2}>
<Box>
<Link to={`/articles/edit/${id}`}>
<CiEdit size={"25px"} cursor={"pointer"} />
</Link>
)}
</Box>

<Box>
<MdDeleteOutline size={"25px"} color="red" cursor={"pointer"} onClick={onDelete} />
</Box>
</Flex>
)}
</Box>

{authorUsername && (
<Heading size="xs" fontSize={"13px"}>
<Box>
<Text
fontSize={"14px"}
lineHeight={"1.7em"}
color={"#0009"}
dangerouslySetInnerHTML={stripTags(truncate(description, 200))}
/>

<Flex flex="1" gap={2} my={"12px"} flexDirection={{ base: "column", md: "row" }}>
<Box display={"flex"} gap={3} alignItems={"center"}>
{authorUsername && (
<Link to={`/user/${authorUsername}`}>
{authorUsername}
<Avatar size={"xs"} name={authorFullname} src={authorAvatar} />
</Link>
</Heading>
)}
</Box>
)}

<Box display={"flex"} gap={3} alignItems={"center"}>
{authorProfileHeadlines && (
<Text fontSize={"12px"} color={"#0009"}>{truncate(authorProfileHeadlines, 60)}</Text>
)}
{authorUsername && (
<Heading size="xs" fontSize={"13px"}>
<Link to={`/user/${authorUsername}`}>
{authorUsername}
</Link>
</Heading>
)}
</Box>

<Text fontSize={"12px"} color={"#0009"}>{read_time}</Text>
</Box>
</Flex>
</Box>
<Box display={"flex"} gap={3} alignItems={"center"}>
{authorProfileHeadlines && (
<Text fontSize={"12px"} color={"#0009"}>{truncate(authorProfileHeadlines, 60)}</Text>
)}

{isOwner && (
<Flex p={"5px"} gap={2}>
<Box>
<Link to={`/articles/edit/${id}`}>
<CiEdit size={"25px"} cursor={"pointer"} />
</Link>
</Box>

<Box>
<MdDeleteOutline size={"25px"} color="red" cursor={"pointer"} onClick={onDelete} />
</Box>
</Flex>
)}
<Text fontSize={"12px"} color={"#0009"}>{read_time}</Text>
</Box>
</Flex>
</Box>
</Box>
</Box>
</Box>
</CardBody>
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/article/useCreateArticleDisLike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const useCreateArticleDisLike = () => {
queryClient.invalidateQueries({
queryKey: ['article']
});

queryClient.invalidateQueries({
queryKey: ['public-author-article']
});
},
onError: (error) => {
errorNotification(error?.message)
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/article/useCreateArticleLike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const useCreateArticleLike = () => {
queryClient.invalidateQueries({
queryKey: ['article']
});

queryClient.invalidateQueries({
queryKey: ['public-author-article']
});
},
onError: (error) => {
errorNotification(error?.message)
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/thread/useCreateThreadDisLike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const useCreateThreadDisLike = () => {
queryClient.invalidateQueries({
queryKey: ['thread']
});

queryClient.invalidateQueries({
queryKey: ['public-author-threads']
});
},
onError: (error) => {
errorNotification(error?.message)
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/thread/useCreateThreadLike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const useCreateThreadLike = () => {
queryClient.invalidateQueries({
queryKey: ['thread']
});

queryClient.invalidateQueries({
queryKey: ['public-author-threads']
});
},
onError: (error) => {
errorNotification(error?.message)
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/thread/useDeleteThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export const useDeleteThread = () => {
queryClient.invalidateQueries({
queryKey: ['thread']
})

queryClient.invalidateQueries({
queryKey: ['public-author-threads']
});
},
onError: (error) => {
errorNotification(error?.message)
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Users/show/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const PublicUserAboutDetails: FunctionComponent<PublicUserAboutDetailsProps> = (
</Text>

<Box mt={"30px"}>
<Text fontSize={"14px"}>Connect with <Text as={"span"} fontWeight={"bold"}>{data?.fullname}</Text></Text>
{data?.twitter && (
<Text fontSize={"14px"}>Connect with <Text as={"span"} fontWeight={"bold"}>{data?.fullname}</Text></Text>
)}

<HStack
spacing={3}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Users/show/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ const ShowUserPublicPosts: FunctionComponent = () => {

const { data, isLoading } = useGetPublicUser(username!)

if (!data) return <NotFound />;


if (isLoading) return <Skeleton />

if (!data) return <NotFound />;

const userData = data?.data;

return (
Expand Down

0 comments on commit 429f79e

Please sign in to comment.