fix: normal share gets attached to previously visited reverse share

This commit is contained in:
Elias Schneider
2025-01-21 18:57:33 +01:00
parent 2b7d3c0a8a
commit 3a534c7512
2 changed files with 8 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ import shareService from "../../services/share.service";
import { FileUpload } from "../../types/File.type";
import { CreateShare, Share } from "../../types/share.type";
import toast from "../../utils/toast.util";
import { useRouter } from "next/router";
const promiseLimit = pLimit(3);
let errorToastShown = false;
@@ -33,6 +34,7 @@ const Upload = ({
simplified: boolean;
}) => {
const modals = useModals();
const router = useRouter();
const t = useTranslate();
const { user } = useUser();
@@ -54,7 +56,8 @@ const Upload = ({
setisUploading(true);
try {
createdShare = await shareService.create(share);
const isReverseShare = router.pathname != "/upload";
createdShare = await shareService.create(share, isReverseShare);
} catch (e) {
toast.axiosError(e);
setisUploading(false);

View File

@@ -15,7 +15,10 @@ const list = async (): Promise<MyShare[]> => {
return (await api.get(`shares/all`)).data;
};
const create = async (share: CreateShare) => {
const create = async (share: CreateShare, isReverseShare = false) => {
if (!isReverseShare) {
deleteCookie("reverse_share_token");
}
return (await api.post("shares", share)).data;
};