bug fixed

This commit is contained in:
daniel31x13 2024-08-16 12:35:04 -04:00
parent 0e47ad9920
commit 5d26617251
3 changed files with 22 additions and 40 deletions

View File

@ -398,14 +398,13 @@ const useBulkEditLinks = () => {
return data.response;
},
onSuccess: (data, { links, newData, removePreviousTags }) => {
queryClient.setQueryData(["dashboardData"], (oldData: any) => {
if (!oldData) return undefined;
return oldData.map((e: any) =>
data.find((d: any) => d.id === e.id) ? data : e
);
});
// TODO: Fix this
// TODO: Fix these
// queryClient.setQueryData(["dashboardData"], (oldData: any) => {
// if (!oldData) return undefined;
// return oldData.map((e: any) =>
// data.find((d: any) => d.id === e.id) ? data : e
// );
// });
// queryClient.setQueriesData({ queryKey: ["links"] }, (oldData: any) => {
// if (!oldData) return undefined;
// return {
@ -417,6 +416,7 @@ const useBulkEditLinks = () => {
// };
// });
queryClient.invalidateQueries({ queryKey: ["links"] }); // Temporary workaround
queryClient.invalidateQueries({ queryKey: ["dashboardData"] }); // Temporary workaround
queryClient.invalidateQueries({ queryKey: ["collections"] });
queryClient.invalidateQueries({ queryKey: ["tags"] });

View File

@ -1,12 +1,4 @@
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
import { Dispatch, SetStateAction } from "react";
const getPublicCollectionData = async (
collectionId: number,
setData: Dispatch<
SetStateAction<CollectionIncludingMembersAndLinkCount | undefined>
>
) => {
const getPublicCollectionData = async (collectionId: number) => {
const res = await fetch("/api/v1/public/collections/" + collectionId);
if (res.status === 400)
@ -14,8 +6,6 @@ const getPublicCollectionData = async (
const data = await res.json();
setData(data.response);
return data;
};

View File

@ -19,7 +19,6 @@ import EditCollectionSharingModal from "@/components/ModalContent/EditCollection
import { useTranslation } from "next-i18next";
import getServerSideProps from "@/lib/client/getServerSideProps";
import LinkListOptions from "@/components/LinkListOptions";
import { useCollections } from "@/hooks/store/collections";
import { usePublicLinks } from "@/hooks/store/publicLinks";
import Links from "@/components/LinkViews/Links";
@ -28,8 +27,6 @@ export default function PublicCollections() {
const { settings } = useLocalSettingsStore();
const { data: collections = [] } = useCollections();
const router = useRouter();
const [collectionOwner, setCollectionOwner] = useState({
@ -71,25 +68,22 @@ export default function PublicCollections() {
useEffect(() => {
if (router.query.id) {
getPublicCollectionData(Number(router.query.id), setCollection).then(
(res) => {
if (res.status === 400) {
router.push("/dashboard");
}
getPublicCollectionData(Number(router.query.id)).then((res) => {
if (res.status === 400) {
router.push("/dashboard");
} else {
setCollection(res.response);
}
);
});
}
}, [collections]);
}, []);
useEffect(() => {
const fetchOwner = async () => {
if (collection) {
const owner = await getPublicUserData(collection.ownerId as number);
setCollectionOwner(owner);
}
};
fetchOwner();
if (collection) {
getPublicUserData(collection.ownerId as number).then((owner) =>
setCollectionOwner(owner)
);
}
}, [collection]);
const [editCollectionSharingModal, setEditCollectionSharingModal] =
@ -236,9 +230,7 @@ export default function PublicCollections() {
placeholderCount={1}
useData={data}
/>
{!data.isLoading && links && !links[0] && (
<p>{t("collection_is_empty")}</p>
)}
{!data.isLoading && links && !links[0] && <p>{t("nothing_found")}</p>}
{/* <p className="text-center text-neutral">
List created with <span className="text-black">Linkwarden.</span>