Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

bug fix

daniel31x13803143299596
diff --git a/components/InstallApp.tsx b/components/InstallApp.tsx
index 4b703093..f191f006 100644
--- a/components/InstallApp.tsx
+++ b/components/InstallApp.tsx
@@ -8,7 +8,7 @@ const InstallApp = (props: Props) => {
const [isOpen, setIsOpen] = useState(true);
return isOpen && !isPWA() ? (
- <div className="absolute left-0 right-0 bottom-10 w-full p-5">
+ <div className="fixed left-0 right-0 bottom-10 w-full p-5">
<div className="mx-auto w-fit p-2 flex justify-between gap-2 items-center border border-neutral-content rounded-xl bg-base-300 backdrop-blur-md bg-opacity-80 max-w-md">
<svg
xmlns="http://www.w3.org/2000/svg"
diff --git a/components/ModalContent/DeleteCollectionModal.tsx b/components/ModalContent/DeleteCollectionModal.tsx
index 359209e7..0aae2988 100644
--- a/components/ModalContent/DeleteCollectionModal.tsx
+++ b/components/ModalContent/DeleteCollectionModal.tsx
@@ -50,8 +50,8 @@ export default function DeleteCollectionModal({
toast.error(error.message);
} else {
onClose();
- router.push("/collections");
toast.success(t("deleted"));
+ router.push("/collections");
}
},
});
diff --git a/components/ModalContent/DeleteLinkModal.tsx b/components/ModalContent/DeleteLinkModal.tsx
index 5a210759..19154d78 100644
--- a/components/ModalContent/DeleteLinkModal.tsx
+++ b/components/ModalContent/DeleteLinkModal.tsx
@@ -37,8 +37,8 @@ export default function DeleteLinkModal({ onClose, activeLink }: Props) {
if (router.pathname.startsWith("/links/[id]")) {
router.push("/dashboard");
}
- onClose();
toast.success(t("deleted"));
+ onClose();
}
},
});
diff --git a/hooks/store/admin/users.tsx b/hooks/store/admin/users.tsx
index ec1e0fd1..476beb35 100644
--- a/hooks/store/admin/users.tsx
+++ b/hooks/store/admin/users.tsx
@@ -1,8 +1,11 @@
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import toast from "react-hot-toast";
import { useTranslation } from "next-i18next";
+import { useSession } from "next-auth/react";
const useUsers = () => {
+ const { status } = useSession();
+
return useQuery({
queryKey: ["users"],
queryFn: async () => {
@@ -17,6 +20,7 @@ const useUsers = () => {
const data = await response.json();
return data.response;
},
+ enabled: status === "authenticated",
});
};
diff --git a/hooks/store/collections.tsx b/hooks/store/collections.tsx
index e16a3269..efa38090 100644
--- a/hooks/store/collections.tsx
+++ b/hooks/store/collections.tsx
@@ -1,7 +1,10 @@
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { CollectionIncludingMembersAndLinkCount } from "@/types/global";
+import { useSession } from "next-auth/react";
const useCollections = () => {
+ const { status } = useSession();
+
return useQuery({
queryKey: ["collections"],
queryFn: async (): Promise<CollectionIncludingMembersAndLinkCount[]> => {
@@ -9,6 +12,7 @@ const useCollections = () => {
const data = await response.json();
return data.response;
},
+ enabled: status === "authenticated",
});
};
diff --git a/hooks/store/dashboardData.tsx b/hooks/store/dashboardData.tsx
index 358b0352..d808ffd0 100644
--- a/hooks/store/dashboardData.tsx
+++ b/hooks/store/dashboardData.tsx
@@ -1,7 +1,10 @@
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
import { useQuery } from "@tanstack/react-query";
+import { useSession } from "next-auth/react";
const useDashboardData = () => {
+ const { status } = useSession();
+
return useQuery({
queryKey: ["dashboardData"],
queryFn: async (): Promise<LinkIncludingShortenedCollectionAndTags[]> => {
@@ -10,6 +13,7 @@ const useDashboardData = () => {
return data.response;
},
+ enabled: status === "authenticated",
});
};
diff --git a/hooks/store/links.tsx b/hooks/store/links.tsx
index da503f41..4702ff41 100644
--- a/hooks/store/links.tsx
+++ b/hooks/store/links.tsx
@@ -12,6 +12,7 @@ import {
LinkRequestQuery,
} from "@/types/global";
import { useRouter } from "next/router";
+import { useSession } from "next-auth/react";
const useLinks = (params: LinkRequestQuery = {}) => {
const router = useRouter();
@@ -58,6 +59,8 @@ const useLinks = (params: LinkRequestQuery = {}) => {
};
const useFetchLinks = (params: string) => {
+ const { status } = useSession();
+
return useInfiniteQuery({
queryKey: ["links", { params }],
queryFn: async (params) => {
@@ -80,6 +83,7 @@ const useFetchLinks = (params: string) => {
}
return lastPage.at(-1).id;
},
+ enabled: status === "authenticated",
});
};
diff --git a/hooks/store/tags.tsx b/hooks/store/tags.tsx
index deab4560..a2c0b7df 100644
--- a/hooks/store/tags.tsx
+++ b/hooks/store/tags.tsx
@@ -1,7 +1,10 @@
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { TagIncludingLinkCount } from "@/types/global";
+import { useSession } from "next-auth/react";
const useTags = () => {
+ const { status } = useSession();
+
return useQuery({
queryKey: ["tags"],
queryFn: async () => {
@@ -11,6 +14,7 @@ const useTags = () => {
const data = await response.json();
return data.response;
},
+ enabled: status === "authenticated",
});
};
diff --git a/hooks/store/tokens.tsx b/hooks/store/tokens.tsx
index b48fce09..35ac345b 100644
--- a/hooks/store/tokens.tsx
+++ b/hooks/store/tokens.tsx
@@ -1,7 +1,10 @@
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { AccessToken } from "@prisma/client";
+import { useSession } from "next-auth/react";
const useTokens = () => {
+ const { status } = useSession();
+
return useQuery({
queryKey: ["tokens"],
queryFn: async () => {
@@ -12,6 +15,7 @@ const useTokens = () => {
const data = await response.json();
return data.response as AccessToken[];
},
+ enabled: status === "authenticated",
});
};
diff --git a/hooks/store/user.tsx b/hooks/store/user.tsx
index 98ba03c1..200fd456 100644
--- a/hooks/store/user.tsx
+++ b/hooks/store/user.tsx
@@ -2,7 +2,7 @@ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { useSession } from "next-auth/react";
const useUser = () => {
- const { data } = useSession();
+ const { data, status } = useSession();
const userId = data?.user.id;
@@ -16,7 +16,7 @@ const useUser = () => {
return data.response;
},
- enabled: !!userId,
+ enabled: !!userId && status === "authenticated",
placeholderData: {},
});
};
diff --git a/hooks/useInitialData.tsx b/hooks/useInitialData.tsx
index 04cf2476..21832d14 100644
--- a/hooks/useInitialData.tsx
+++ b/hooks/useInitialData.tsx
@@ -1,24 +1,14 @@
import { useEffect } from "react";
import { useSession } from "next-auth/react";
import useLocalSettingsStore from "@/store/localSettings";
-import { useUser } from "./store/user";
export default function useInitialData() {
const { status, data } = useSession();
- // const { setLinks } = useLinkStore();
- const { data: user = {} } = useUser();
const { setSettings } = useLocalSettingsStore();
useEffect(() => {
setSettings();
}, [status, data]);
- // Get the rest of the data
- useEffect(() => {
- if (user.id && (!process.env.NEXT_PUBLIC_STRIPE || user.username)) {
- // setLinks();
- }
- }, [user]);
-
return status;
}
diff --git a/hooks/useReorderCollection.tsx b/hooks/useReorderCollection.tsx
deleted file mode 100644
index e69de29b..00000000
diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx
index c96f8070..5ff146fb 100644
--- a/pages/collections/[id].tsx
+++ b/pages/collections/[id].tsx
@@ -322,7 +322,7 @@ export default function Index() {
placeholderCount={1}
useData={data}
/>
- {!data.isLoading && !links[0] && <NoLinksFound />}
+ {!data.isLoading && links && !links[0] && <NoLinksFound />}
</div>
{activeCollection && (
<>
diff --git a/pages/links/index.tsx b/pages/links/index.tsx
index 7b1e5390..582e9620 100644
--- a/pages/links/index.tsx
+++ b/pages/links/index.tsx
@@ -58,7 +58,7 @@ export default function Index() {
placeholderCount={1}
useData={data}
/>
- {!data.isLoading && !links[0] && (
+ {!data.isLoading && links && !links[0] && (
<NoLinksFound text={t("you_have_not_added_any_links")} />
)}
</div>
diff --git a/pages/links/pinned.tsx b/pages/links/pinned.tsx
index 3f59c448..9d1fb53d 100644
--- a/pages/links/pinned.tsx
+++ b/pages/links/pinned.tsx
@@ -53,7 +53,7 @@ export default function PinnedLinks() {
placeholderCount={1}
useData={data}
/>
- {!data.isLoading && !links[0] && (
+ {!data.isLoading && links && !links[0] && (
<div
style={{ flex: "1 1 auto" }}
className="flex flex-col gap-2 justify-center h-full w-full mx-auto p-10"
diff --git a/pages/public/collections/[id].tsx b/pages/public/collections/[id].tsx
index 27007965..c2229dc4 100644
--- a/pages/public/collections/[id].tsx
+++ b/pages/public/collections/[id].tsx
@@ -230,7 +230,9 @@ export default function PublicCollections() {
placeholderCount={1}
useData={data}
/>
- {!data.isLoading && !links[0] && <p>{t("collection_is_empty")}</p>}
+ {!data.isLoading && links && !links[0] && (
+ <p>{t("collection_is_empty")}</p>
+ )}
{/* <p className="text-center text-neutral">
List created with <span className="text-black">Linkwarden.</span>
diff --git a/pages/settings/account.tsx b/pages/settings/account.tsx
index 06d1172a..ded46838 100644
--- a/pages/settings/account.tsx
+++ b/pages/settings/account.tsx
@@ -203,17 +203,14 @@ export default function Account() {
<div>
<p className="mb-2">{t("language")}</p>
<select
+ value={user.locale || ""}
onChange={(e) => {
setUser({ ...user, locale: e.target.value });
}}
className="select border border-neutral-content focus:outline-none focus:border-primary duration-100 w-full bg-base-200 rounded-[0.375rem] min-h-0 h-[2.625rem] leading-4 p-2"
>
{i18n.locales.map((locale) => (
- <option
- key={locale}
- value={locale}
- selected={user.locale === locale}
- >
+ <option key={locale} value={locale}>
{new Intl.DisplayNames(locale, { type: "language" }).of(
locale
) || ""}
diff --git a/pages/tags/[id].tsx b/pages/tags/[id].tsx
index 1d00b81b..55262ab4 100644
--- a/pages/tags/[id].tsx
+++ b/pages/tags/[id].tsx
@@ -114,8 +114,8 @@ export default function Index() {
if (error) {
toast.error(error.message);
} else {
- router.push("/links");
toast.success(t("tag_deleted"));
+ router.push("/links");
}
},
});
diff --git a/public/locales/en/common.json b/public/locales/en/common.json
index 868fac03..734340db 100644
--- a/public/locales/en/common.json
+++ b/public/locales/en/common.json
@@ -297,6 +297,7 @@
"create_new_collection": "Create a New Collection",
"color": "Color",
"reset": "Reset",
+ "updating_collection": "Updating Collection...",
"collection_name_placeholder": "e.g. Example Collection",
"collection_description_placeholder": "The purpose of this Collection...",
"create_collection_button": "Create Collection",