fix: normal share gets attached to previously visited reverse share
This commit is contained in:
@@ -18,6 +18,7 @@ import shareService from "../../services/share.service";
|
|||||||
import { FileUpload } from "../../types/File.type";
|
import { FileUpload } from "../../types/File.type";
|
||||||
import { CreateShare, Share } from "../../types/share.type";
|
import { CreateShare, Share } from "../../types/share.type";
|
||||||
import toast from "../../utils/toast.util";
|
import toast from "../../utils/toast.util";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
const promiseLimit = pLimit(3);
|
const promiseLimit = pLimit(3);
|
||||||
let errorToastShown = false;
|
let errorToastShown = false;
|
||||||
@@ -33,6 +34,7 @@ const Upload = ({
|
|||||||
simplified: boolean;
|
simplified: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const modals = useModals();
|
const modals = useModals();
|
||||||
|
const router = useRouter();
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
|
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
@@ -54,7 +56,8 @@ const Upload = ({
|
|||||||
setisUploading(true);
|
setisUploading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
createdShare = await shareService.create(share);
|
const isReverseShare = router.pathname != "/upload";
|
||||||
|
createdShare = await shareService.create(share, isReverseShare);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast.axiosError(e);
|
toast.axiosError(e);
|
||||||
setisUploading(false);
|
setisUploading(false);
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ const list = async (): Promise<MyShare[]> => {
|
|||||||
return (await api.get(`shares/all`)).data;
|
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;
|
return (await api.post("shares", share)).data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user