Skip to content

Commit

Permalink
fix: resolve cache issue in profile
Browse files Browse the repository at this point in the history
  • Loading branch information
joshxfi committed Apr 24, 2024
1 parent 5045228 commit cc39da4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 956 deletions.
4 changes: 2 additions & 2 deletions src/app/dashboard/components/profile/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FragmentOf, graphql, readFragment } from "gql.tada";

import { EditIcon } from "@/components/icons";
import { Button, buttonVariants } from "@/components/ui/button";
import { buttonVariants } from "@/components/ui/button";

import { OrgSheet } from "../org-sheet";
import { PaymentMethod } from "../payment-method";
Expand Down Expand Up @@ -38,7 +38,7 @@ export function ProfileSidebar({
const data = readFragment(SidebarFields, user);

return (
<aside className="w-2/3 space-y-4">
<aside className="w-2/3 space-y-4 hidden lg:block">
<div className="p-6 bg-white shadow-sm rounded-md items-center">
<div className="flex justify-between mb-2">
<h3 className="text-base font-semibold">About</h3>
Expand Down
21 changes: 19 additions & 2 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ const GetUserQuery = graphql(
[BannerFields, PostFields, SidebarFields],
);

const GetPostsQuery = graphql(
`
query GetPosts {
posts {
id
...PostFields
}
}
`,
[PostFields],
);

function Profile() {
const { data: session } = useSession();

Expand All @@ -46,19 +58,24 @@ function Profile() {
pause: !session?.user.id,
});

const [posts] = useQuery({
query: GetPostsQuery,
pause: !session?.user.id,
});

return (
<section className="max-w-screen-lg mx-auto">
{result.data?.getUser && (
<>
<ProfileBanner user={result.data.getUser} />

<div className="flex space-x-4">
<div className="flex lg:space-x-4">
<ProfileSidebar user={result.data?.getUser} />

<div className="w-full space-y-4">
<PostForm />
<div className="space-y-4 w-full">
{result.data?.getUser.posts.map((post) => (
{posts.data?.posts.map((post) => (
<Post key={post.id} post={post} />
))}
</div>
Expand Down
Loading

0 comments on commit cc39da4

Please sign in to comment.