Skip to content

Commit 9ea4a40

Browse files
authored
Preserve forked package visibility (#2428)
1 parent 9341b6c commit 9ea4a40

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/components/ViewPackagePage/components/package-header.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ export default function PackageHeader({
6565

6666
const handleForkClick = async () => {
6767
if (!packageInfo?.package_id || !isLoggedIn) return
68-
await forkPackage(packageInfo.package_id)
68+
await forkPackage({
69+
packageId: packageInfo.package_id,
70+
isPrivate,
71+
})
6972
}
7073

7174
useEffect(() => {

src/hooks/use-fork-package-mutation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ export const useForkPackageMutation = ({
1515

1616
return useMutation(
1717
["forkPackage"],
18-
async (packageId: string) => {
18+
async ({
19+
packageId,
20+
isPrivate,
21+
}: {
22+
packageId: string
23+
isPrivate?: boolean
24+
}) => {
1925
if (!session) throw new Error("No session")
2026

2127
const { data } = await axios.post("/packages/fork", {
2228
package_id: packageId,
29+
is_private: isPrivate,
2330
})
2431

2532
const forkedPackage: Package = data.package

src/hooks/useForkPackageMutation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const useForkPackageMutation = ({
2525

2626
const { data } = await axios.post("/packages/fork", {
2727
package_id: pkg?.package_id,
28+
is_private: pkg?.is_private,
2829
})
2930
return data.package
3031
},

0 commit comments

Comments
 (0)