From 242ed6162e971d5631ba98ce80340acca723ef78 Mon Sep 17 00:00:00 2001 From: Can Sirin <8138047+cansirin@users.noreply.github.com> Date: Thu, 10 Aug 2023 21:33:57 -0700 Subject: [PATCH 1/8] feat(apps/pano): use relay in post more options --- apps/kampus/app/pano/PanoFeed.tsx | 12 +- apps/kampus/app/pano/PostListContainer.tsx | 6 +- .../PanoFeedPaginationQuery.graphql.ts | 15 ++- .../__generated__/PanoFeed_viewer.graphql.ts | 42 +++++++ .../PostListContainerQuery.graphql.ts | 74 +++++++++--- .../pano/features/post-list/MoreOptions.tsx | 109 ++++++++++-------- .../app/pano/features/post-list/PostItem.tsx | 6 +- .../__generated__/MoreOptions_post.graphql.ts | 63 ++++++++++ .../__generated__/PostItem_post.graphql.ts | 11 +- 9 files changed, 264 insertions(+), 74 deletions(-) create mode 100644 apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts create mode 100644 apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_post.graphql.ts diff --git a/apps/kampus/app/pano/PanoFeed.tsx b/apps/kampus/app/pano/PanoFeed.tsx index 661e7a6e..5b9d0daf 100644 --- a/apps/kampus/app/pano/PanoFeed.tsx +++ b/apps/kampus/app/pano/PanoFeed.tsx @@ -1,9 +1,10 @@ import { Suspense, useCallback } from "react"; -import { graphql, usePaginationFragment } from "react-relay"; +import { graphql, useFragment, usePaginationFragment } from "react-relay"; import { Button } from "@kampus/ui-next"; import { PostItem } from "~/app/pano/features/post-list/PostItem"; +import { PanoFeed_viewer$key } from "./__generated__/PanoFeed_viewer.graphql"; import { type PanoFeedFragment$key } from "./__generated__/PanoFeedFragment.graphql"; const fragment = graphql` @@ -28,8 +29,15 @@ const fragment = graphql` } `; +const viewerFragment = graphql` + fragment PanoFeed_viewer on Actor { + displayName + } +`; + interface Props { panoFeed: PanoFeedFragment$key; + panoViewer: PanoFeed_viewer$key | null; } export function PanoFeed(props: Props) { @@ -37,6 +45,8 @@ export function PanoFeed(props: Props) { fragment, props.panoFeed ); + const viewer = useFragment(viewerFragment, props.panoViewer); + console.log(viewer, "-------------------viewer"); const feed = data.panoFeed; diff --git a/apps/kampus/app/pano/PostListContainer.tsx b/apps/kampus/app/pano/PostListContainer.tsx index eee9c796..c96f1d55 100644 --- a/apps/kampus/app/pano/PostListContainer.tsx +++ b/apps/kampus/app/pano/PostListContainer.tsx @@ -16,6 +16,9 @@ const query = graphql` query PostListContainerQuery { viewer { ...PanoFeedFragment + actor { + ...PanoFeed_viewer + } } } `; @@ -23,10 +26,11 @@ const query = graphql` export const PostListContainer = (props: Props) => { const queryRef = useSerializablePreloadedQuery(props.preloadedQuery); const data = usePreloadedQuery(query, queryRef); + console.log(data); if (!data.viewer) { return null; } - return ; + return ; }; diff --git a/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts index e6de5cd9..1133daed 100644 --- a/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<09ed6683c9184c2f89dbaad228142867>> + * @generated SignedSource<<721d372d9c0d61484976ff4a06abe9e0>> * @lightSyntaxTransform * @nogrep */ @@ -215,7 +215,14 @@ return { "name": "displayName", "storageKey": null }, - (v2/*: any*/) + (v2/*: any*/), + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "username", + "storageKey": null + } ], "storageKey": null }, @@ -289,12 +296,12 @@ return { ] }, "params": { - "cacheID": "4ca0994c46e6a44f1dc573f87eb2c3b6", + "cacheID": "a62d5eaf7fdd72aabe8f4b44402e9534", "id": null, "metadata": {}, "name": "PanoFeedPaginationQuery", "operationKind": "query", - "text": "query PanoFeedPaginationQuery(\n $after: String\n $before: String\n $first: Int = 10\n $last: Int\n) {\n viewer {\n ...PanoFeedFragment_pbnwq\n }\n}\n\nfragment PanoFeedFragment_pbnwq on Viewer {\n panoFeed(first: $first, after: $after, last: $last, before: $before) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" + "text": "query PanoFeedPaginationQuery(\n $after: String\n $before: String\n $first: Int = 10\n $last: Int\n) {\n viewer {\n ...PanoFeedFragment_pbnwq\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n username\n id\n }\n}\n\nfragment PanoFeedFragment_pbnwq on Viewer {\n panoFeed(first: $first, after: $after, last: $last, before: $before) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" } }; })(); diff --git a/apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts b/apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts new file mode 100644 index 00000000..57438047 --- /dev/null +++ b/apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts @@ -0,0 +1,42 @@ +/** + * @generated SignedSource<<6909702fcff66160abb20fbbfeab1e64>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { Fragment, ReaderFragment } from 'relay-runtime'; +import { FragmentRefs } from "relay-runtime"; +export type PanoFeed_viewer$data = { + readonly displayName: string | null; + readonly " $fragmentType": "PanoFeed_viewer"; +}; +export type PanoFeed_viewer$key = { + readonly " $data"?: PanoFeed_viewer$data; + readonly " $fragmentSpreads": FragmentRefs<"PanoFeed_viewer">; +}; + +const node: ReaderFragment = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "PanoFeed_viewer", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "displayName", + "storageKey": null + } + ], + "type": "Actor", + "abstractKey": "__isActor" +}; + +(node as any).hash = "d899f3d2a551aba8616408feb294eb54"; + +export default node; diff --git a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts index 967966b2..dd07a0a1 100644 --- a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -13,6 +13,9 @@ import { FragmentRefs } from "relay-runtime"; export type PostListContainerQuery$variables = {}; export type PostListContainerQuery$data = { readonly viewer: { + readonly actor: { + readonly " $fragmentSpreads": FragmentRefs<"PanoFeed_viewer">; + } | null; readonly " $fragmentSpreads": FragmentRefs<"PanoFeedFragment">; } | null; }; @@ -35,6 +38,20 @@ v1 = { "kind": "ScalarField", "name": "id", "storageKey": null +}, +v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "displayName", + "storageKey": null +}, +v3 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null }; return { "fragment": { @@ -55,6 +72,22 @@ return { "args": null, "kind": "FragmentSpread", "name": "PanoFeedFragment" + }, + { + "alias": null, + "args": null, + "concreteType": null, + "kind": "LinkedField", + "name": "actor", + "plural": false, + "selections": [ + { + "args": null, + "kind": "FragmentSpread", + "name": "PanoFeed_viewer" + } + ], + "storageKey": null } ], "storageKey": null @@ -166,24 +199,19 @@ return { "name": "owner", "plural": false, "selections": [ + (v2/*: any*/), + (v1/*: any*/), { "alias": null, "args": null, "kind": "ScalarField", - "name": "displayName", + "name": "username", "storageKey": null - }, - (v1/*: any*/) + } ], "storageKey": null }, - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "__typename", - "storageKey": null - } + (v3/*: any*/) ], "storageKey": null } @@ -240,6 +268,24 @@ return { "key": "PanoFeedFragment__panoFeed", "kind": "LinkedHandle", "name": "panoFeed" + }, + { + "alias": null, + "args": null, + "concreteType": null, + "kind": "LinkedField", + "name": "actor", + "plural": false, + "selections": [ + (v3/*: any*/), + { + "kind": "TypeDiscriminator", + "abstractKey": "__isActor" + }, + (v2/*: any*/), + (v1/*: any*/) + ], + "storageKey": null } ], "storageKey": null @@ -247,16 +293,16 @@ return { ] }, "params": { - "cacheID": "18eb8eaf3693895b2efd987ddc3b9362", + "cacheID": "03884b4e86f1ba9d6723df79bf407499", "id": null, "metadata": {}, "name": "PostListContainerQuery", "operationKind": "query", - "text": "query PostListContainerQuery {\n viewer {\n ...PanoFeedFragment\n }\n}\n\nfragment PanoFeedFragment on Viewer {\n panoFeed(first: 10) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" + "text": "query PostListContainerQuery {\n viewer {\n ...PanoFeedFragment\n actor {\n __typename\n ...PanoFeed_viewer\n id\n }\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n username\n id\n }\n}\n\nfragment PanoFeedFragment on Viewer {\n panoFeed(first: 10) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PanoFeed_viewer on Actor {\n __isActor: __typename\n displayName\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" } }; })(); -(node as any).hash = "38254b185df77d46946b76194dd61219"; +(node as any).hash = "1a56ce0599346554f35cba75e9ef0e29"; export default node; diff --git a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx index 66955884..f685cedd 100644 --- a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx +++ b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx @@ -1,7 +1,8 @@ "use client"; -import { useRouter } from "next/navigation"; +import Link from "next/link"; import { MoreHorizontal } from "lucide-react"; +import { graphql, useFragment } from "react-relay"; import { Button, @@ -20,53 +21,55 @@ import { useToast, } from "@kampus/ui-next"; +import { MoreOptions_post$key } from "./__generated__/MoreOptions_post.graphql"; + interface Props { - post: Post; - shareUrl: string; + post: MoreOptions_post$key; } -type Post = { - __typename?: "PanoPost"; - content: string; - createdAt: string; - id: string; - owner: string; - title: string; - url: string; -}; -type User = { - username: string; -}; +const moreOptionsPostFragment = graphql` + fragment MoreOptions_post on PanoPost { + id + owner { + username + } + } +`; -function canUserEdit(user: User, post: Post) { - console.log(user, post); - return true; -} +// const moreOptionsViewerFragment = graphql` +// fragment MoreOptions_viewer on Actor { +// displayName +// id +// } +// `; -export const MoreOptionsDropdown = ({ post, shareUrl }: Props) => { - const user = { username: "John Doe" }; - console.log(post, shareUrl); +function canUserEdit(session?: any, owner?: any) { + if (!owner) return false; + if (!session) return false; - const router = useRouter(); + const username = session.user?.name; + return username === owner; +} + +export const MoreOptionsDropdown = (props: Props) => { + const post = useFragment(moreOptionsPostFragment, props.post); + // const viewer = useFragment(moreOptionsViewerFragment, props.viewer); const { toast } = useToast(); const ownerItems: JSX.Element[] = []; - if (canUserEdit(user, post)) { - ownerItems.push( - router.push(`/posts/${post.id}/edit`)} key="edit"> - Düzenle - - ); - ownerItems.push( - - Sil - - ); - ownerItems.push(); - } - - // // FIXME: below appears to be redundant, is it? - // const menuItems = [...ownerItems]; + // if (canUserEdit(session, post.owner?.username)) { + ownerItems.push( + + Düzenle + + ); + ownerItems.push( + + Sil + + ); + ownerItems.push(); + // } return ( @@ -77,16 +80,26 @@ export const MoreOptionsDropdown = ({ post, shareUrl }: Props) => { - {ownerItems} + {canUserEdit({ user: { name: "can" } }, "can") && ( + <> + + Düzenle + + + Sil + + + + )} { - toast({ - description: "Link kopyalandı", - }); - }} - > - Linki kopyala - + onSelect={() => { + toast({ + description: "Link kopyalandı", + }); + }} + > + Linki kopyala + diff --git a/apps/kampus/app/pano/features/post-list/PostItem.tsx b/apps/kampus/app/pano/features/post-list/PostItem.tsx index 0fa7f3a3..e3f98c46 100644 --- a/apps/kampus/app/pano/features/post-list/PostItem.tsx +++ b/apps/kampus/app/pano/features/post-list/PostItem.tsx @@ -7,10 +7,9 @@ import { cn } from "@kampus/ui-next/utils"; import { TimeAgo } from "~/../../packages/ui"; import { type PostItem_post$key } from "./__generated__/PostItem_post.graphql"; +import { MoreOptionsDropdown } from "./MoreOptions"; import { UpvoteButton } from "./PostUpvoteButton"; -// import { MoreOptionsDropdown } from "./MoreOptions"; - interface LinkProps { href: string; children: string; @@ -34,7 +33,6 @@ const usePanoPostFragment = (key: PostItem_post$key | null) => content url createdAt - id site ...PostUpvoteButton_post @@ -42,6 +40,7 @@ const usePanoPostFragment = (key: PostItem_post$key | null) => owner @required(action: LOG) { displayName @required(action: LOG) } + ...MoreOptions_post } `, key @@ -78,6 +77,7 @@ export const PostItem = (props: PostItemProps) => { 0 yorum | + diff --git a/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_post.graphql.ts b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_post.graphql.ts new file mode 100644 index 00000000..0c6bf70e --- /dev/null +++ b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_post.graphql.ts @@ -0,0 +1,63 @@ +/** + * @generated SignedSource<<789c3dcce5dd3bfead2297a6ac6667d5>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { Fragment, ReaderFragment } from 'relay-runtime'; +import { FragmentRefs } from "relay-runtime"; +export type MoreOptions_post$data = { + readonly id: string; + readonly owner: { + readonly username: string; + } | null; + readonly " $fragmentType": "MoreOptions_post"; +}; +export type MoreOptions_post$key = { + readonly " $data"?: MoreOptions_post$data; + readonly " $fragmentSpreads": FragmentRefs<"MoreOptions_post">; +}; + +const node: ReaderFragment = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "MoreOptions_post", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "User", + "kind": "LinkedField", + "name": "owner", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "username", + "storageKey": null + } + ], + "storageKey": null + } + ], + "type": "PanoPost", + "abstractKey": null +}; + +(node as any).hash = "9d3d7c45939c77a59da8a5829f1aa5c2"; + +export default node; diff --git a/apps/kampus/app/pano/features/post-list/__generated__/PostItem_post.graphql.ts b/apps/kampus/app/pano/features/post-list/__generated__/PostItem_post.graphql.ts index a1c7259d..d7bae815 100644 --- a/apps/kampus/app/pano/features/post-list/__generated__/PostItem_post.graphql.ts +++ b/apps/kampus/app/pano/features/post-list/__generated__/PostItem_post.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -20,7 +20,7 @@ export type PostItem_post$data = { readonly site: string | null; readonly title: string; readonly url: string | null; - readonly " $fragmentSpreads": FragmentRefs<"PostUpvoteButton_post">; + readonly " $fragmentSpreads": FragmentRefs<"MoreOptions_post" | "PostUpvoteButton_post">; readonly " $fragmentType": "PostItem_post"; } | null; export type PostItem_post$key = { @@ -108,12 +108,17 @@ const node: ReaderFragment = { }, "action": "LOG", "path": "owner" + }, + { + "args": null, + "kind": "FragmentSpread", + "name": "MoreOptions_post" } ], "type": "PanoPost", "abstractKey": null }; -(node as any).hash = "2722b74002976e15c158a0be92853b78"; +(node as any).hash = "40952525253258c86b4d4320cf4279a0"; export default node; From 1410b1d5a556a606020c18c4557d53b1f33a0d36 Mon Sep 17 00:00:00 2001 From: Can Sirin <8138047+cansirin@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:38:54 -0700 Subject: [PATCH 2/8] get viewer name for MoreOptions --- apps/kampus/app/pano/PanoFeed.tsx | 9 ++- apps/kampus/app/pano/PostListContainer.tsx | 7 +-- .../__generated__/PanoFeed_viewer.graphql.ts | 16 +++--- .../PostListContainerQuery.graphql.ts | 32 +++-------- .../pano/features/post-list/MoreOptions.tsx | 47 ++++++++++------ .../app/pano/features/post-list/PostItem.tsx | 15 ++++- .../MoreOptions_viewer.graphql.ts | 55 +++++++++++++++++++ .../__generated__/PostItem_viewer.graphql.ts | 40 ++++++++++++++ 8 files changed, 158 insertions(+), 63 deletions(-) create mode 100644 apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_viewer.graphql.ts create mode 100644 apps/kampus/app/pano/features/post-list/__generated__/PostItem_viewer.graphql.ts diff --git a/apps/kampus/app/pano/PanoFeed.tsx b/apps/kampus/app/pano/PanoFeed.tsx index 5b9d0daf..56373144 100644 --- a/apps/kampus/app/pano/PanoFeed.tsx +++ b/apps/kampus/app/pano/PanoFeed.tsx @@ -30,14 +30,14 @@ const fragment = graphql` `; const viewerFragment = graphql` - fragment PanoFeed_viewer on Actor { - displayName + fragment PanoFeed_viewer on Viewer { + ...PostItem_viewer } `; interface Props { panoFeed: PanoFeedFragment$key; - panoViewer: PanoFeed_viewer$key | null; + panoViewer: PanoFeed_viewer$key; } export function PanoFeed(props: Props) { @@ -46,7 +46,6 @@ export function PanoFeed(props: Props) { props.panoFeed ); const viewer = useFragment(viewerFragment, props.panoViewer); - console.log(viewer, "-------------------viewer"); const feed = data.panoFeed; @@ -70,7 +69,7 @@ export function PanoFeed(props: Props) { return null; } - return ; + return ; })}
diff --git a/apps/kampus/app/pano/PostListContainer.tsx b/apps/kampus/app/pano/PostListContainer.tsx index c96f1d55..d3a93228 100644 --- a/apps/kampus/app/pano/PostListContainer.tsx +++ b/apps/kampus/app/pano/PostListContainer.tsx @@ -16,9 +16,7 @@ const query = graphql` query PostListContainerQuery { viewer { ...PanoFeedFragment - actor { - ...PanoFeed_viewer - } + ...PanoFeed_viewer } } `; @@ -26,11 +24,10 @@ const query = graphql` export const PostListContainer = (props: Props) => { const queryRef = useSerializablePreloadedQuery(props.preloadedQuery); const data = usePreloadedQuery(query, queryRef); - console.log(data); if (!data.viewer) { return null; } - return ; + return ; }; diff --git a/apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts b/apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts index 57438047..a1aeb7a0 100644 --- a/apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PanoFeed_viewer.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<6909702fcff66160abb20fbbfeab1e64>> + * @generated SignedSource<<285a7607218f1bcd3ce4cf4f6613f8d0>> * @lightSyntaxTransform * @nogrep */ @@ -11,7 +11,7 @@ import { Fragment, ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; export type PanoFeed_viewer$data = { - readonly displayName: string | null; + readonly " $fragmentSpreads": FragmentRefs<"PostItem_viewer">; readonly " $fragmentType": "PanoFeed_viewer"; }; export type PanoFeed_viewer$key = { @@ -26,17 +26,15 @@ const node: ReaderFragment = { "name": "PanoFeed_viewer", "selections": [ { - "alias": null, "args": null, - "kind": "ScalarField", - "name": "displayName", - "storageKey": null + "kind": "FragmentSpread", + "name": "PostItem_viewer" } ], - "type": "Actor", - "abstractKey": "__isActor" + "type": "Viewer", + "abstractKey": null }; -(node as any).hash = "d899f3d2a551aba8616408feb294eb54"; +(node as any).hash = "aa9717b7dd3561c13af770ff24544e2d"; export default node; diff --git a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts index dd07a0a1..e8ce0120 100644 --- a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -13,10 +13,7 @@ import { FragmentRefs } from "relay-runtime"; export type PostListContainerQuery$variables = {}; export type PostListContainerQuery$data = { readonly viewer: { - readonly actor: { - readonly " $fragmentSpreads": FragmentRefs<"PanoFeed_viewer">; - } | null; - readonly " $fragmentSpreads": FragmentRefs<"PanoFeedFragment">; + readonly " $fragmentSpreads": FragmentRefs<"PanoFeedFragment" | "PanoFeed_viewer">; } | null; }; export type PostListContainerQuery = { @@ -74,20 +71,9 @@ return { "name": "PanoFeedFragment" }, { - "alias": null, "args": null, - "concreteType": null, - "kind": "LinkedField", - "name": "actor", - "plural": false, - "selections": [ - { - "args": null, - "kind": "FragmentSpread", - "name": "PanoFeed_viewer" - } - ], - "storageKey": null + "kind": "FragmentSpread", + "name": "PanoFeed_viewer" } ], "storageKey": null @@ -278,10 +264,6 @@ return { "plural": false, "selections": [ (v3/*: any*/), - { - "kind": "TypeDiscriminator", - "abstractKey": "__isActor" - }, (v2/*: any*/), (v1/*: any*/) ], @@ -293,16 +275,16 @@ return { ] }, "params": { - "cacheID": "03884b4e86f1ba9d6723df79bf407499", + "cacheID": "f17705aca1c90be09fad072eb42c4786", "id": null, "metadata": {}, "name": "PostListContainerQuery", "operationKind": "query", - "text": "query PostListContainerQuery {\n viewer {\n ...PanoFeedFragment\n actor {\n __typename\n ...PanoFeed_viewer\n id\n }\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n username\n id\n }\n}\n\nfragment PanoFeedFragment on Viewer {\n panoFeed(first: 10) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PanoFeed_viewer on Actor {\n __isActor: __typename\n displayName\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" + "text": "query PostListContainerQuery {\n viewer {\n ...PanoFeedFragment\n ...PanoFeed_viewer\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n username\n id\n }\n}\n\nfragment MoreOptions_viewer on Viewer {\n actor {\n __typename\n displayName\n id\n }\n}\n\nfragment PanoFeedFragment on Viewer {\n panoFeed(first: 10) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PanoFeed_viewer on Viewer {\n ...PostItem_viewer\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostItem_viewer on Viewer {\n ...MoreOptions_viewer\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" } }; })(); -(node as any).hash = "1a56ce0599346554f35cba75e9ef0e29"; +(node as any).hash = "246fd8479a18172b183f288ff6f3e842"; export default node; diff --git a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx index f685cedd..f2851838 100644 --- a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx +++ b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx @@ -22,26 +22,37 @@ import { } from "@kampus/ui-next"; import { MoreOptions_post$key } from "./__generated__/MoreOptions_post.graphql"; +import { MoreOptions_viewer$key } from "./__generated__/MoreOptions_viewer.graphql"; interface Props { post: MoreOptions_post$key; + viewerRef: MoreOptions_viewer$key | null; } -const moreOptionsPostFragment = graphql` - fragment MoreOptions_post on PanoPost { - id - owner { - username - } - } -`; +const useMoreOptionsPostFragment = (key: MoreOptions_post$key | null) => + useFragment( + graphql` + fragment MoreOptions_post on PanoPost { + id + owner { + username + } + } + `, + key + ); -// const moreOptionsViewerFragment = graphql` -// fragment MoreOptions_viewer on Actor { -// displayName -// id -// } -// `; +const useMoreOptionsViewerFragment = (key: MoreOptions_viewer$key | null) => + useFragment( + graphql` + fragment MoreOptions_viewer on Viewer { + actor { + displayName + } + } + `, + key + ); function canUserEdit(session?: any, owner?: any) { if (!owner) return false; @@ -52,15 +63,15 @@ function canUserEdit(session?: any, owner?: any) { } export const MoreOptionsDropdown = (props: Props) => { - const post = useFragment(moreOptionsPostFragment, props.post); - // const viewer = useFragment(moreOptionsViewerFragment, props.viewer); + const post = useMoreOptionsPostFragment(props.post); + const viewer = useMoreOptionsViewerFragment(props.viewerRef); const { toast } = useToast(); const ownerItems: JSX.Element[] = []; // if (canUserEdit(session, post.owner?.username)) { ownerItems.push( - Düzenle + Düzenle ); ownerItems.push( @@ -83,7 +94,7 @@ export const MoreOptionsDropdown = (props: Props) => { {canUserEdit({ user: { name: "can" } }, "can") && ( <> - Düzenle + Düzenle Sil diff --git a/apps/kampus/app/pano/features/post-list/PostItem.tsx b/apps/kampus/app/pano/features/post-list/PostItem.tsx index e3f98c46..ae35785e 100644 --- a/apps/kampus/app/pano/features/post-list/PostItem.tsx +++ b/apps/kampus/app/pano/features/post-list/PostItem.tsx @@ -7,6 +7,7 @@ import { cn } from "@kampus/ui-next/utils"; import { TimeAgo } from "~/../../packages/ui"; import { type PostItem_post$key } from "./__generated__/PostItem_post.graphql"; +import { type PostItem_viewer$key } from "./__generated__/PostItem_viewer.graphql"; import { MoreOptionsDropdown } from "./MoreOptions"; import { UpvoteButton } from "./PostUpvoteButton"; @@ -46,13 +47,25 @@ const usePanoPostFragment = (key: PostItem_post$key | null) => key ); +const usePanoViewerFragment = (key: PostItem_viewer$key | null) => + useFragment( + graphql` + fragment PostItem_viewer on Viewer { + ...MoreOptions_viewer + } + `, + key + ); + interface PostItemProps { post: PostItem_post$key; + viewerRef: PostItem_viewer$key; showContent?: boolean; } export const PostItem = (props: PostItemProps) => { const post = usePanoPostFragment(props.post); + const viewer = usePanoViewerFragment(props.viewerRef); if (!post) { return null; @@ -77,7 +90,7 @@ export const PostItem = (props: PostItemProps) => { 0 yorum |
- + diff --git a/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_viewer.graphql.ts b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_viewer.graphql.ts new file mode 100644 index 00000000..ef707e16 --- /dev/null +++ b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_viewer.graphql.ts @@ -0,0 +1,55 @@ +/** + * @generated SignedSource<> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { Fragment, ReaderFragment } from 'relay-runtime'; +import { FragmentRefs } from "relay-runtime"; +export type MoreOptions_viewer$data = { + readonly actor: { + readonly displayName: string | null; + } | null; + readonly " $fragmentType": "MoreOptions_viewer"; +}; +export type MoreOptions_viewer$key = { + readonly " $data"?: MoreOptions_viewer$data; + readonly " $fragmentSpreads": FragmentRefs<"MoreOptions_viewer">; +}; + +const node: ReaderFragment = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "MoreOptions_viewer", + "selections": [ + { + "alias": null, + "args": null, + "concreteType": null, + "kind": "LinkedField", + "name": "actor", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "displayName", + "storageKey": null + } + ], + "storageKey": null + } + ], + "type": "Viewer", + "abstractKey": null +}; + +(node as any).hash = "335429bfb4234ab199c74e1828e9bfe2"; + +export default node; diff --git a/apps/kampus/app/pano/features/post-list/__generated__/PostItem_viewer.graphql.ts b/apps/kampus/app/pano/features/post-list/__generated__/PostItem_viewer.graphql.ts new file mode 100644 index 00000000..91e7ebb0 --- /dev/null +++ b/apps/kampus/app/pano/features/post-list/__generated__/PostItem_viewer.graphql.ts @@ -0,0 +1,40 @@ +/** + * @generated SignedSource<> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { Fragment, ReaderFragment } from 'relay-runtime'; +import { FragmentRefs } from "relay-runtime"; +export type PostItem_viewer$data = { + readonly " $fragmentSpreads": FragmentRefs<"MoreOptions_viewer">; + readonly " $fragmentType": "PostItem_viewer"; +}; +export type PostItem_viewer$key = { + readonly " $data"?: PostItem_viewer$data; + readonly " $fragmentSpreads": FragmentRefs<"PostItem_viewer">; +}; + +const node: ReaderFragment = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "PostItem_viewer", + "selections": [ + { + "args": null, + "kind": "FragmentSpread", + "name": "MoreOptions_viewer" + } + ], + "type": "Viewer", + "abstractKey": null +}; + +(node as any).hash = "691b7ff06781176ab6c92034830657db"; + +export default node; From 018023faea8fae0ba5a7f2b1e0a1cd7d2d6c9670 Mon Sep 17 00:00:00 2001 From: Can Sirin <8138047+cansirin@users.noreply.github.com> Date: Fri, 11 Aug 2023 21:17:53 -0700 Subject: [PATCH 3/8] fix(apps/pano): get display name instead username --- .../PanoFeedPaginationQuery.graphql.ts | 15 +++-------- .../PostListContainerQuery.graphql.ts | 15 +++-------- .../pano/features/post-list/MoreOptions.tsx | 26 ++++--------------- .../__generated__/MoreOptions_post.graphql.ts | 8 +++--- 4 files changed, 17 insertions(+), 47 deletions(-) diff --git a/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts index 1133daed..d652c2a1 100644 --- a/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<721d372d9c0d61484976ff4a06abe9e0>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -215,14 +215,7 @@ return { "name": "displayName", "storageKey": null }, - (v2/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "username", - "storageKey": null - } + (v2/*: any*/) ], "storageKey": null }, @@ -296,12 +289,12 @@ return { ] }, "params": { - "cacheID": "a62d5eaf7fdd72aabe8f4b44402e9534", + "cacheID": "2fa3d4b245b0acc80462563f1be852b7", "id": null, "metadata": {}, "name": "PanoFeedPaginationQuery", "operationKind": "query", - "text": "query PanoFeedPaginationQuery(\n $after: String\n $before: String\n $first: Int = 10\n $last: Int\n) {\n viewer {\n ...PanoFeedFragment_pbnwq\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n username\n id\n }\n}\n\nfragment PanoFeedFragment_pbnwq on Viewer {\n panoFeed(first: $first, after: $after, last: $last, before: $before) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" + "text": "query PanoFeedPaginationQuery(\n $after: String\n $before: String\n $first: Int = 10\n $last: Int\n) {\n viewer {\n ...PanoFeedFragment_pbnwq\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n displayName\n id\n }\n}\n\nfragment PanoFeedFragment_pbnwq on Viewer {\n panoFeed(first: $first, after: $after, last: $last, before: $before) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" } }; })(); diff --git a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts index e8ce0120..be0b0390 100644 --- a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -186,14 +186,7 @@ return { "plural": false, "selections": [ (v2/*: any*/), - (v1/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "username", - "storageKey": null - } + (v1/*: any*/) ], "storageKey": null }, @@ -275,12 +268,12 @@ return { ] }, "params": { - "cacheID": "f17705aca1c90be09fad072eb42c4786", + "cacheID": "ce044815e675e6ab754d1c6c36828dc6", "id": null, "metadata": {}, "name": "PostListContainerQuery", "operationKind": "query", - "text": "query PostListContainerQuery {\n viewer {\n ...PanoFeedFragment\n ...PanoFeed_viewer\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n username\n id\n }\n}\n\nfragment MoreOptions_viewer on Viewer {\n actor {\n __typename\n displayName\n id\n }\n}\n\nfragment PanoFeedFragment on Viewer {\n panoFeed(first: 10) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PanoFeed_viewer on Viewer {\n ...PostItem_viewer\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostItem_viewer on Viewer {\n ...MoreOptions_viewer\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" + "text": "query PostListContainerQuery {\n viewer {\n ...PanoFeedFragment\n ...PanoFeed_viewer\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n displayName\n id\n }\n}\n\nfragment MoreOptions_viewer on Viewer {\n actor {\n __typename\n displayName\n id\n }\n}\n\nfragment PanoFeedFragment on Viewer {\n panoFeed(first: 10) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PanoFeed_viewer on Viewer {\n ...PostItem_viewer\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostItem_viewer on Viewer {\n ...MoreOptions_viewer\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" } }; })(); diff --git a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx index f2851838..c185c144 100644 --- a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx +++ b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx @@ -35,7 +35,7 @@ const useMoreOptionsPostFragment = (key: MoreOptions_post$key | null) => fragment MoreOptions_post on PanoPost { id owner { - username + displayName } } `, @@ -54,11 +54,10 @@ const useMoreOptionsViewerFragment = (key: MoreOptions_viewer$key | null) => key ); -function canUserEdit(session?: any, owner?: any) { +function canUserEdit(username?: string | null, owner?: string | null) { if (!owner) return false; - if (!session) return false; + if (!username) return false; - const username = session.user?.name; return username === owner; } @@ -67,21 +66,6 @@ export const MoreOptionsDropdown = (props: Props) => { const viewer = useMoreOptionsViewerFragment(props.viewerRef); const { toast } = useToast(); - const ownerItems: JSX.Element[] = []; - // if (canUserEdit(session, post.owner?.username)) { - ownerItems.push( - - Düzenle - - ); - ownerItems.push( - - Sil - - ); - ownerItems.push(); - // } - return ( @@ -91,9 +75,9 @@ export const MoreOptionsDropdown = (props: Props) => { - {canUserEdit({ user: { name: "can" } }, "can") && ( + {canUserEdit(viewer?.actor?.displayName, post?.owner?.displayName) && ( <> - + Düzenle diff --git a/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_post.graphql.ts b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_post.graphql.ts index 0c6bf70e..3f0a86bd 100644 --- a/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_post.graphql.ts +++ b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptions_post.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<789c3dcce5dd3bfead2297a6ac6667d5>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -13,7 +13,7 @@ import { FragmentRefs } from "relay-runtime"; export type MoreOptions_post$data = { readonly id: string; readonly owner: { - readonly username: string; + readonly displayName: string | null; } | null; readonly " $fragmentType": "MoreOptions_post"; }; @@ -47,7 +47,7 @@ const node: ReaderFragment = { "alias": null, "args": null, "kind": "ScalarField", - "name": "username", + "name": "displayName", "storageKey": null } ], @@ -58,6 +58,6 @@ const node: ReaderFragment = { "abstractKey": null }; -(node as any).hash = "9d3d7c45939c77a59da8a5829f1aa5c2"; +(node as any).hash = "01fe2324527daa720ea5ca88add6406c"; export default node; From 83700750b5314be27bf56d5d02b147abc89781fe Mon Sep 17 00:00:00 2001 From: Can Sirin <8138047+cansirin@users.noreply.github.com> Date: Fri, 11 Aug 2023 21:19:50 -0700 Subject: [PATCH 4/8] fix(apps/pano): fix build errors --- apps/kampus/app/pano/PanoFeed.tsx | 2 +- apps/kampus/app/pano/features/post-list/MoreOptions.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/kampus/app/pano/PanoFeed.tsx b/apps/kampus/app/pano/PanoFeed.tsx index 56373144..b7767cd1 100644 --- a/apps/kampus/app/pano/PanoFeed.tsx +++ b/apps/kampus/app/pano/PanoFeed.tsx @@ -4,7 +4,7 @@ import { graphql, useFragment, usePaginationFragment } from "react-relay"; import { Button } from "@kampus/ui-next"; import { PostItem } from "~/app/pano/features/post-list/PostItem"; -import { PanoFeed_viewer$key } from "./__generated__/PanoFeed_viewer.graphql"; +import { type PanoFeed_viewer$key } from "./__generated__/PanoFeed_viewer.graphql"; import { type PanoFeedFragment$key } from "./__generated__/PanoFeedFragment.graphql"; const fragment = graphql` diff --git a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx index c185c144..63333bfe 100644 --- a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx +++ b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx @@ -21,8 +21,8 @@ import { useToast, } from "@kampus/ui-next"; -import { MoreOptions_post$key } from "./__generated__/MoreOptions_post.graphql"; -import { MoreOptions_viewer$key } from "./__generated__/MoreOptions_viewer.graphql"; +import { type MoreOptions_post$key } from "./__generated__/MoreOptions_post.graphql"; +import { type MoreOptions_viewer$key } from "./__generated__/MoreOptions_viewer.graphql"; interface Props { post: MoreOptions_post$key; From b6805147af4e7d340072d5d0d10a35b0fe6786c4 Mon Sep 17 00:00:00 2001 From: Can Sirin <8138047+cansirin@users.noreply.github.com> Date: Sun, 13 Aug 2023 11:22:12 -0700 Subject: [PATCH 5/8] feat(apps/pano): add delete mutation --- apps/kampus/app/pano/PanoFeed.tsx | 11 +- .../__generated__/PanoFeedFragment.graphql.ts | 24 ++- .../PanoFeedPaginationQuery.graphql.ts | 20 +- .../PostListContainerQuery.graphql.ts | 26 ++- .../pano/features/post-list/MoreOptions.tsx | 78 +++++--- .../app/pano/features/post-list/PostItem.tsx | 13 +- .../MoreOptionsRemotePostMutation.graphql.ts | 189 ++++++++++++++++++ .../__generated__/PostItem_viewer.graphql.ts | 25 ++- 8 files changed, 342 insertions(+), 44 deletions(-) create mode 100644 apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemotePostMutation.graphql.ts diff --git a/apps/kampus/app/pano/PanoFeed.tsx b/apps/kampus/app/pano/PanoFeed.tsx index b7767cd1..d1db1260 100644 --- a/apps/kampus/app/pano/PanoFeed.tsx +++ b/apps/kampus/app/pano/PanoFeed.tsx @@ -18,9 +18,11 @@ const fragment = graphql` @refetchable(queryName: "PanoFeedPaginationQuery") { panoFeed(first: $first, after: $after, last: $last, before: $before) @connection(key: "PanoFeedFragment__panoFeed") { + __id edges { cursor node { + __id id ...PostItem_post } @@ -69,7 +71,14 @@ export function PanoFeed(props: Props) { return null; } - return ; + return ( + + ); })}
diff --git a/apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts b/apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts index e80778c7..05534b34 100644 --- a/apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<3c9f3f7de053b4688b2404c72e9daa59>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -12,9 +12,11 @@ import { ReaderFragment, RefetchableFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; export type PanoFeedFragment$data = { readonly panoFeed: { + readonly __id: string; readonly edges: ReadonlyArray<{ readonly cursor: string; readonly node: { + readonly __id: string; readonly id: string; readonly " $fragmentSpreads": FragmentRefs<"PostItem_post">; } | null; @@ -30,7 +32,19 @@ export type PanoFeedFragment$key = { const node: ReaderFragment = (function(){ var v0 = [ "panoFeed" -]; +], +v1 = { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] +}; return { "argumentDefinitions": [ { @@ -127,6 +141,7 @@ return { "kind": "FragmentSpread", "name": "PostItem_post" }, + (v1/*: any*/), { "alias": null, "args": null, @@ -178,7 +193,8 @@ return { } ], "storageKey": null - } + }, + (v1/*: any*/) ], "storageKey": null } @@ -188,6 +204,6 @@ return { }; })(); -(node as any).hash = "c0d59088c3d65e88fdd5d8da836c2d76"; +(node as any).hash = "8221de534510fed35dd0d645b9b44259"; export default node; diff --git a/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts index d652c2a1..428e8e91 100644 --- a/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<98e2a5455bce95d44527b69e9a38256a>> * @lightSyntaxTransform * @nogrep */ @@ -77,6 +77,18 @@ v2 = { "kind": "ScalarField", "name": "id", "storageKey": null +}, +v3 = { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] }; return { "fragment": { @@ -219,6 +231,7 @@ return { ], "storageKey": null }, + (v3/*: any*/), { "alias": null, "args": null, @@ -270,7 +283,8 @@ return { } ], "storageKey": null - } + }, + (v3/*: any*/) ], "storageKey": null }, @@ -299,6 +313,6 @@ return { }; })(); -(node as any).hash = "c0d59088c3d65e88fdd5d8da836c2d76"; +(node as any).hash = "8221de534510fed35dd0d645b9b44259"; export default node; diff --git a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts index be0b0390..577e9dfc 100644 --- a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<1e355bbc68aacef6b1d9586fde987101>> * @lightSyntaxTransform * @nogrep */ @@ -44,6 +44,18 @@ v2 = { "storageKey": null }, v3 = { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] +}, +v4 = { "alias": null, "args": null, "kind": "ScalarField", @@ -190,7 +202,8 @@ return { ], "storageKey": null }, - (v3/*: any*/) + (v3/*: any*/), + (v4/*: any*/) ], "storageKey": null } @@ -235,7 +248,8 @@ return { } ], "storageKey": null - } + }, + (v3/*: any*/) ], "storageKey": "panoFeed(first:10)" }, @@ -256,7 +270,7 @@ return { "name": "actor", "plural": false, "selections": [ - (v3/*: any*/), + (v4/*: any*/), (v2/*: any*/), (v1/*: any*/) ], @@ -268,12 +282,12 @@ return { ] }, "params": { - "cacheID": "ce044815e675e6ab754d1c6c36828dc6", + "cacheID": "8d8a203cd59b6775cfbc8daaad9001ef", "id": null, "metadata": {}, "name": "PostListContainerQuery", "operationKind": "query", - "text": "query PostListContainerQuery {\n viewer {\n ...PanoFeedFragment\n ...PanoFeed_viewer\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n displayName\n id\n }\n}\n\nfragment MoreOptions_viewer on Viewer {\n actor {\n __typename\n displayName\n id\n }\n}\n\nfragment PanoFeedFragment on Viewer {\n panoFeed(first: 10) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PanoFeed_viewer on Viewer {\n ...PostItem_viewer\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostItem_viewer on Viewer {\n ...MoreOptions_viewer\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" + "text": "query PostListContainerQuery {\n viewer {\n ...PanoFeedFragment\n ...PanoFeed_viewer\n }\n}\n\nfragment MoreOptions_post on PanoPost {\n id\n owner {\n displayName\n id\n }\n}\n\nfragment MoreOptions_viewer on Viewer {\n actor {\n __typename\n displayName\n id\n }\n}\n\nfragment PanoFeedFragment on Viewer {\n panoFeed(first: 10) {\n edges {\n cursor\n node {\n id\n ...PostItem_post\n __typename\n }\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n}\n\nfragment PanoFeed_viewer on Viewer {\n ...PostItem_viewer\n}\n\nfragment PostItem_post on PanoPost {\n id\n title\n content\n url\n createdAt\n site\n ...PostUpvoteButton_post\n owner {\n displayName\n id\n }\n ...MoreOptions_post\n}\n\nfragment PostItem_viewer on Viewer {\n ...MoreOptions_viewer\n actor {\n __typename\n displayName\n id\n }\n}\n\nfragment PostUpvoteButton_post on PanoPost {\n id\n isUpvotedByViewer\n upvoteCount\n}\n" } }; })(); diff --git a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx index 63333bfe..3944b811 100644 --- a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx +++ b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx @@ -2,17 +2,19 @@ import Link from "next/link"; import { MoreHorizontal } from "lucide-react"; -import { graphql, useFragment } from "react-relay"; +import { graphql, useFragment, useMutation } from "react-relay"; import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, Button, - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuItem, @@ -27,6 +29,7 @@ import { type MoreOptions_viewer$key } from "./__generated__/MoreOptions_viewer. interface Props { post: MoreOptions_post$key; viewerRef: MoreOptions_viewer$key | null; + postConnectionId?: string; } const useMoreOptionsPostFragment = (key: MoreOptions_post$key | null) => @@ -54,6 +57,19 @@ const useMoreOptionsViewerFragment = (key: MoreOptions_viewer$key | null) => key ); +const remotePostMutation = graphql` + mutation MoreOptionsRemotePostMutation($connections: [ID!]!, $postID: ID!) { + removePanoPost(input: { id: $postID }) { + edge { + node { + id @deleteEdge(connections: $connections) + title + } + } + } + } +`; + function canUserEdit(username?: string | null, owner?: string | null) { if (!owner) return false; if (!username) return false; @@ -65,9 +81,21 @@ export const MoreOptionsDropdown = (props: Props) => { const post = useMoreOptionsPostFragment(props.post); const viewer = useMoreOptionsViewerFragment(props.viewerRef); const { toast } = useToast(); + const [removePost, isRemoving] = useMutation(remotePostMutation); + + const onClick = () => { + if (!post) { + return; + } + if (isRemoving) { + return; + } + + removePost({ variables: { postID: post.id, connections: [props.postConnectionId] } }); + }; return ( - + - - - - + + + + Hayır + Evet + + + ); }; diff --git a/apps/kampus/app/pano/features/post-list/PostItem.tsx b/apps/kampus/app/pano/features/post-list/PostItem.tsx index ae35785e..8a6b4e33 100644 --- a/apps/kampus/app/pano/features/post-list/PostItem.tsx +++ b/apps/kampus/app/pano/features/post-list/PostItem.tsx @@ -52,6 +52,9 @@ const usePanoViewerFragment = (key: PostItem_viewer$key | null) => graphql` fragment PostItem_viewer on Viewer { ...MoreOptions_viewer + actor { + displayName + } } `, key @@ -61,6 +64,7 @@ interface PostItemProps { post: PostItem_post$key; viewerRef: PostItem_viewer$key; showContent?: boolean; + postConnectionId?: string; } export const PostItem = (props: PostItemProps) => { @@ -71,6 +75,8 @@ export const PostItem = (props: PostItemProps) => { return null; } + console.log(viewer, "viewer"); + return (
@@ -90,7 +96,12 @@ export const PostItem = (props: PostItemProps) => { 0 yorum |
- + diff --git a/apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemotePostMutation.graphql.ts b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemotePostMutation.graphql.ts new file mode 100644 index 00000000..13942505 --- /dev/null +++ b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemotePostMutation.graphql.ts @@ -0,0 +1,189 @@ +/** + * @generated SignedSource<<4310a943f342f4775027fa0ff214c999>> + * @lightSyntaxTransform + * @nogrep + */ + +/* tslint:disable */ +/* eslint-disable */ +// @ts-nocheck + +import { ConcreteRequest, Mutation } from 'relay-runtime'; +export type MoreOptionsRemotePostMutation$variables = { + connections: ReadonlyArray; + postID: string; +}; +export type MoreOptionsRemotePostMutation$data = { + readonly removePanoPost: { + readonly edge: { + readonly node: { + readonly id: string; + readonly title: string; + } | null; + } | null; + } | null; +}; +export type MoreOptionsRemotePostMutation = { + response: MoreOptionsRemotePostMutation$data; + variables: MoreOptionsRemotePostMutation$variables; +}; + +const node: ConcreteRequest = (function(){ +var v0 = [ + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "connections" + }, + { + "defaultValue": null, + "kind": "LocalArgument", + "name": "postID" + } +], +v1 = [ + { + "fields": [ + { + "kind": "Variable", + "name": "id", + "variableName": "postID" + } + ], + "kind": "ObjectValue", + "name": "input" + } +], +v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null +}, +v3 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "title", + "storageKey": null +}; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "MoreOptionsRemotePostMutation", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": "RemovePanoPostPayload", + "kind": "LinkedField", + "name": "removePanoPost", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "PanoPostEdge", + "kind": "LinkedField", + "name": "edge", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "PanoPost", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v2/*: any*/), + (v3/*: any*/) + ], + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": null + } + ], + "type": "Mutation", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "MoreOptionsRemotePostMutation", + "selections": [ + { + "alias": null, + "args": (v1/*: any*/), + "concreteType": "RemovePanoPostPayload", + "kind": "LinkedField", + "name": "removePanoPost", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "PanoPostEdge", + "kind": "LinkedField", + "name": "edge", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "PanoPost", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v2/*: any*/), + { + "alias": null, + "args": null, + "filters": null, + "handle": "deleteEdge", + "key": "", + "kind": "ScalarHandle", + "name": "id", + "handleArgs": [ + { + "kind": "Variable", + "name": "connections", + "variableName": "connections" + } + ] + }, + (v3/*: any*/) + ], + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": null + } + ] + }, + "params": { + "cacheID": "97a33e0cf008ffdcd790abdec86cc134", + "id": null, + "metadata": {}, + "name": "MoreOptionsRemotePostMutation", + "operationKind": "mutation", + "text": "mutation MoreOptionsRemotePostMutation(\n $postID: ID!\n) {\n removePanoPost(input: {id: $postID}) {\n edge {\n node {\n id\n title\n }\n }\n }\n}\n" + } +}; +})(); + +(node as any).hash = "38f8dec25a77178637e1b25506d773e1"; + +export default node; diff --git a/apps/kampus/app/pano/features/post-list/__generated__/PostItem_viewer.graphql.ts b/apps/kampus/app/pano/features/post-list/__generated__/PostItem_viewer.graphql.ts index 91e7ebb0..3a5b3b4f 100644 --- a/apps/kampus/app/pano/features/post-list/__generated__/PostItem_viewer.graphql.ts +++ b/apps/kampus/app/pano/features/post-list/__generated__/PostItem_viewer.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<4b69c454a3a58b7052f9e79ba03b1bec>> * @lightSyntaxTransform * @nogrep */ @@ -11,6 +11,9 @@ import { Fragment, ReaderFragment } from 'relay-runtime'; import { FragmentRefs } from "relay-runtime"; export type PostItem_viewer$data = { + readonly actor: { + readonly displayName: string | null; + } | null; readonly " $fragmentSpreads": FragmentRefs<"MoreOptions_viewer">; readonly " $fragmentType": "PostItem_viewer"; }; @@ -29,12 +32,30 @@ const node: ReaderFragment = { "args": null, "kind": "FragmentSpread", "name": "MoreOptions_viewer" + }, + { + "alias": null, + "args": null, + "concreteType": null, + "kind": "LinkedField", + "name": "actor", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "displayName", + "storageKey": null + } + ], + "storageKey": null } ], "type": "Viewer", "abstractKey": null }; -(node as any).hash = "691b7ff06781176ab6c92034830657db"; +(node as any).hash = "08a45a50da6ade7e46c243f7477d30ac"; export default node; From ddbaabbab3deec5e53522608c97977b7ac1383a2 Mon Sep 17 00:00:00 2001 From: Can Sirin Date: Sun, 13 Aug 2023 13:21:27 -0700 Subject: [PATCH 6/8] Update apps/kampus/app/pano/features/post-list/PostItem.tsx Co-authored-by: Umut Sirin --- apps/kampus/app/pano/features/post-list/PostItem.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/kampus/app/pano/features/post-list/PostItem.tsx b/apps/kampus/app/pano/features/post-list/PostItem.tsx index 8a6b4e33..9b3498c9 100644 --- a/apps/kampus/app/pano/features/post-list/PostItem.tsx +++ b/apps/kampus/app/pano/features/post-list/PostItem.tsx @@ -75,8 +75,6 @@ export const PostItem = (props: PostItemProps) => { return null; } - console.log(viewer, "viewer"); - return (
From 1bed14305dc5017a9964109960b5637ceb21d82a Mon Sep 17 00:00:00 2001 From: Can Sirin Date: Sun, 13 Aug 2023 13:21:33 -0700 Subject: [PATCH 7/8] Update apps/kampus/app/pano/PanoFeed.tsx Co-authored-by: Umut Sirin --- apps/kampus/app/pano/PanoFeed.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/kampus/app/pano/PanoFeed.tsx b/apps/kampus/app/pano/PanoFeed.tsx index d1db1260..569b375a 100644 --- a/apps/kampus/app/pano/PanoFeed.tsx +++ b/apps/kampus/app/pano/PanoFeed.tsx @@ -22,7 +22,6 @@ const fragment = graphql` edges { cursor node { - __id id ...PostItem_post } From 00c7fcccde00a11ca8bc2f991960141053e885d7 Mon Sep 17 00:00:00 2001 From: Can Sirin <8138047+cansirin@users.noreply.github.com> Date: Sun, 13 Aug 2023 13:23:41 -0700 Subject: [PATCH 8/8] fix(apps/pano): rename mutation name --- .../__generated__/PanoFeedFragment.graphql.ts | 33 +++++++++---------- .../PanoFeedPaginationQuery.graphql.ts | 30 ++++++++--------- .../PostListContainerQuery.graphql.ts | 32 +++++++++--------- .../pano/features/post-list/MoreOptions.tsx | 8 +++-- ... MoreOptionsRemovePostMutation.graphql.ts} | 24 +++++++------- 5 files changed, 61 insertions(+), 66 deletions(-) rename apps/kampus/app/pano/features/post-list/__generated__/{MoreOptionsRemotePostMutation.graphql.ts => MoreOptionsRemovePostMutation.graphql.ts} (86%) diff --git a/apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts b/apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts index 05534b34..fae43885 100644 --- a/apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PanoFeedFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<845cce7dd6f615c692812a518c6c92de>> * @lightSyntaxTransform * @nogrep */ @@ -16,7 +16,6 @@ export type PanoFeedFragment$data = { readonly edges: ReadonlyArray<{ readonly cursor: string; readonly node: { - readonly __id: string; readonly id: string; readonly " $fragmentSpreads": FragmentRefs<"PostItem_post">; } | null; @@ -32,19 +31,7 @@ export type PanoFeedFragment$key = { const node: ReaderFragment = (function(){ var v0 = [ "panoFeed" -], -v1 = { - "kind": "ClientExtension", - "selections": [ - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "__id", - "storageKey": null - } - ] -}; +]; return { "argumentDefinitions": [ { @@ -141,7 +128,6 @@ return { "kind": "FragmentSpread", "name": "PostItem_post" }, - (v1/*: any*/), { "alias": null, "args": null, @@ -194,7 +180,18 @@ return { ], "storageKey": null }, - (v1/*: any*/) + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] + } ], "storageKey": null } @@ -204,6 +201,6 @@ return { }; })(); -(node as any).hash = "8221de534510fed35dd0d645b9b44259"; +(node as any).hash = "169d642e0dd7ef004b6ba9327f096aca"; export default node; diff --git a/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts index 428e8e91..cf2714ab 100644 --- a/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PanoFeedPaginationQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<98e2a5455bce95d44527b69e9a38256a>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -77,18 +77,6 @@ v2 = { "kind": "ScalarField", "name": "id", "storageKey": null -}, -v3 = { - "kind": "ClientExtension", - "selections": [ - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "__id", - "storageKey": null - } - ] }; return { "fragment": { @@ -231,7 +219,6 @@ return { ], "storageKey": null }, - (v3/*: any*/), { "alias": null, "args": null, @@ -284,7 +271,18 @@ return { ], "storageKey": null }, - (v3/*: any*/) + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] + } ], "storageKey": null }, @@ -313,6 +311,6 @@ return { }; })(); -(node as any).hash = "8221de534510fed35dd0d645b9b44259"; +(node as any).hash = "169d642e0dd7ef004b6ba9327f096aca"; export default node; diff --git a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts index 577e9dfc..4a3edfd9 100644 --- a/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts +++ b/apps/kampus/app/pano/__generated__/PostListContainerQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<1e355bbc68aacef6b1d9586fde987101>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -44,18 +44,6 @@ v2 = { "storageKey": null }, v3 = { - "kind": "ClientExtension", - "selections": [ - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "__id", - "storageKey": null - } - ] -}, -v4 = { "alias": null, "args": null, "kind": "ScalarField", @@ -202,8 +190,7 @@ return { ], "storageKey": null }, - (v3/*: any*/), - (v4/*: any*/) + (v3/*: any*/) ], "storageKey": null } @@ -249,7 +236,18 @@ return { ], "storageKey": null }, - (v3/*: any*/) + { + "kind": "ClientExtension", + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__id", + "storageKey": null + } + ] + } ], "storageKey": "panoFeed(first:10)" }, @@ -270,7 +268,7 @@ return { "name": "actor", "plural": false, "selections": [ - (v4/*: any*/), + (v3/*: any*/), (v2/*: any*/), (v1/*: any*/) ], diff --git a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx index 3944b811..9bf7cc2a 100644 --- a/apps/kampus/app/pano/features/post-list/MoreOptions.tsx +++ b/apps/kampus/app/pano/features/post-list/MoreOptions.tsx @@ -57,8 +57,8 @@ const useMoreOptionsViewerFragment = (key: MoreOptions_viewer$key | null) => key ); -const remotePostMutation = graphql` - mutation MoreOptionsRemotePostMutation($connections: [ID!]!, $postID: ID!) { +const removePostMutation = graphql` + mutation MoreOptionsRemovePostMutation($connections: [ID!]!, $postID: ID!) { removePanoPost(input: { id: $postID }) { edge { node { @@ -70,6 +70,7 @@ const remotePostMutation = graphql` } `; +// TODO: move this to server side function canUserEdit(username?: string | null, owner?: string | null) { if (!owner) return false; if (!username) return false; @@ -81,7 +82,7 @@ export const MoreOptionsDropdown = (props: Props) => { const post = useMoreOptionsPostFragment(props.post); const viewer = useMoreOptionsViewerFragment(props.viewerRef); const { toast } = useToast(); - const [removePost, isRemoving] = useMutation(remotePostMutation); + const [removePost, isRemoving] = useMutation(removePostMutation); const onClick = () => { if (!post) { @@ -94,6 +95,7 @@ export const MoreOptionsDropdown = (props: Props) => { removePost({ variables: { postID: post.id, connections: [props.postConnectionId] } }); }; + return ( diff --git a/apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemotePostMutation.graphql.ts b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemovePostMutation.graphql.ts similarity index 86% rename from apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemotePostMutation.graphql.ts rename to apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemovePostMutation.graphql.ts index 13942505..c0c26e25 100644 --- a/apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemotePostMutation.graphql.ts +++ b/apps/kampus/app/pano/features/post-list/__generated__/MoreOptionsRemovePostMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<4310a943f342f4775027fa0ff214c999>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -9,11 +9,11 @@ // @ts-nocheck import { ConcreteRequest, Mutation } from 'relay-runtime'; -export type MoreOptionsRemotePostMutation$variables = { +export type MoreOptionsRemovePostMutation$variables = { connections: ReadonlyArray; postID: string; }; -export type MoreOptionsRemotePostMutation$data = { +export type MoreOptionsRemovePostMutation$data = { readonly removePanoPost: { readonly edge: { readonly node: { @@ -23,9 +23,9 @@ export type MoreOptionsRemotePostMutation$data = { } | null; } | null; }; -export type MoreOptionsRemotePostMutation = { - response: MoreOptionsRemotePostMutation$data; - variables: MoreOptionsRemotePostMutation$variables; +export type MoreOptionsRemovePostMutation = { + response: MoreOptionsRemovePostMutation$data; + variables: MoreOptionsRemovePostMutation$variables; }; const node: ConcreteRequest = (function(){ @@ -73,7 +73,7 @@ return { "argumentDefinitions": (v0/*: any*/), "kind": "Fragment", "metadata": null, - "name": "MoreOptionsRemotePostMutation", + "name": "MoreOptionsRemovePostMutation", "selections": [ { "alias": null, @@ -118,7 +118,7 @@ return { "operation": { "argumentDefinitions": (v0/*: any*/), "kind": "Operation", - "name": "MoreOptionsRemotePostMutation", + "name": "MoreOptionsRemovePostMutation", "selections": [ { "alias": null, @@ -174,16 +174,16 @@ return { ] }, "params": { - "cacheID": "97a33e0cf008ffdcd790abdec86cc134", + "cacheID": "6c9942183f760e86a8cbfcf94dbc7ebe", "id": null, "metadata": {}, - "name": "MoreOptionsRemotePostMutation", + "name": "MoreOptionsRemovePostMutation", "operationKind": "mutation", - "text": "mutation MoreOptionsRemotePostMutation(\n $postID: ID!\n) {\n removePanoPost(input: {id: $postID}) {\n edge {\n node {\n id\n title\n }\n }\n }\n}\n" + "text": "mutation MoreOptionsRemovePostMutation(\n $postID: ID!\n) {\n removePanoPost(input: {id: $postID}) {\n edge {\n node {\n id\n title\n }\n }\n }\n}\n" } }; })(); -(node as any).hash = "38f8dec25a77178637e1b25506d773e1"; +(node as any).hash = "0bc137edfc163648cc5c8a5969e5697a"; export default node;