Skip to content

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

add initialData to queries

daniel31x13a73e5fa6c641
diff --git a/components/CollectionCard.tsx b/components/CollectionCard.tsx
index bb3a3dd6..9a47f6ee 100644
--- a/components/CollectionCard.tsx
+++ b/components/CollectionCard.tsx
@@ -20,7 +20,7 @@ type Props = {
export default function CollectionCard({ collection, className }: Props) {
const { t } = useTranslation();
const { settings } = useLocalSettingsStore();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const formattedDate = new Date(collection.createdAt as string).toLocaleString(
"en-US",
diff --git a/components/CollectionListing.tsx b/components/CollectionListing.tsx
index 75b12cc2..df85572e 100644
--- a/components/CollectionListing.tsx
+++ b/components/CollectionListing.tsx
@@ -25,9 +25,9 @@ interface ExtendedTreeItem extends TreeItem {
const CollectionListing = () => {
const { t } = useTranslation();
const updateCollection = useUpdateCollection();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const updateUser = useUpdateUser();
const router = useRouter();
diff --git a/components/InputSelect/CollectionSelection.tsx b/components/InputSelect/CollectionSelection.tsx
index 81bef390..24700c20 100644
--- a/components/InputSelect/CollectionSelection.tsx
+++ b/components/InputSelect/CollectionSelection.tsx
@@ -24,7 +24,7 @@ export default function CollectionSelection({
showDefaultValue = true,
creatable = true,
}: Props) {
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
const router = useRouter();
diff --git a/components/InputSelect/TagSelection.tsx b/components/InputSelect/TagSelection.tsx
index efd246b7..c9d3c27d 100644
--- a/components/InputSelect/TagSelection.tsx
+++ b/components/InputSelect/TagSelection.tsx
@@ -13,7 +13,7 @@ type Props = {
};
export default function TagSelection({ onChange, defaultValue }: Props) {
- const { data: tags = [] } = useTags();
+ const { data: tags } = useTags();
const [options, setOptions] = useState<Options[]>([]);
diff --git a/components/LinkViews/LinkCard.tsx b/components/LinkViews/LinkCard.tsx
index e28ee9c2..d6df2b3c 100644
--- a/components/LinkViews/LinkCard.tsx
+++ b/components/LinkViews/LinkCard.tsx
@@ -34,9 +34,9 @@ export default function LinkCard({ link, flipDropdown, editMode }: Props) {
const { t } = useTranslation();
const viewMode = localStorage.getItem("viewMode") || "card";
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const { links, getLink, setSelectedLinks, selectedLinks } = useLinkStore();
diff --git a/components/LinkViews/LinkComponents/LinkActions.tsx b/components/LinkViews/LinkComponents/LinkActions.tsx
index 0a3775e2..430577b5 100644
--- a/components/LinkViews/LinkComponents/LinkActions.tsx
+++ b/components/LinkViews/LinkComponents/LinkActions.tsx
@@ -39,7 +39,7 @@ export default function LinkActions({
const [deleteLinkModal, setDeleteLinkModal] = useState(false);
const [preservedFormatsModal, setPreservedFormatsModal] = useState(false);
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const { removeLink, updateLink } = useLinkStore();
diff --git a/components/LinkViews/LinkList.tsx b/components/LinkViews/LinkList.tsx
index 9755ad9b..5711838d 100644
--- a/components/LinkViews/LinkList.tsx
+++ b/components/LinkViews/LinkList.tsx
@@ -33,9 +33,9 @@ export default function LinkCardCompact({
}: Props) {
const { t } = useTranslation();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const { links, setSelectedLinks, selectedLinks } = useLinkStore();
useEffect(() => {
diff --git a/components/LinkViews/LinkMasonry.tsx b/components/LinkViews/LinkMasonry.tsx
index ca05f1a3..35cbaa94 100644
--- a/components/LinkViews/LinkMasonry.tsx
+++ b/components/LinkViews/LinkMasonry.tsx
@@ -33,8 +33,8 @@ type Props = {
export default function LinkMasonry({ link, flipDropdown, editMode }: Props) {
const { t } = useTranslation();
- const { data: collections = [] } = useCollections();
- const { data: user = [] } = useUser();
+ const { data: collections } = useCollections();
+ const { data: user } = useUser();
const { links, getLink, setSelectedLinks, selectedLinks } = useLinkStore();
diff --git a/components/ModalContent/EditCollectionSharingModal.tsx b/components/ModalContent/EditCollectionSharingModal.tsx
index 158f817f..b1af6a4e 100644
--- a/components/ModalContent/EditCollectionSharingModal.tsx
+++ b/components/ModalContent/EditCollectionSharingModal.tsx
@@ -46,7 +46,7 @@ export default function EditCollectionSharingModal({
}
};
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const permissions = usePermissions(collection.id as number);
const currentURL = new URL(document.URL);
diff --git a/components/ModalContent/NewLinkModal.tsx b/components/ModalContent/NewLinkModal.tsx
index 5164789d..16c84892 100644
--- a/components/ModalContent/NewLinkModal.tsx
+++ b/components/ModalContent/NewLinkModal.tsx
@@ -43,7 +43,7 @@ export default function NewLinkModal({ onClose }: Props) {
const [submitLoader, setSubmitLoader] = useState(false);
const [optionsExpanded, setOptionsExpanded] = useState(false);
const router = useRouter();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
const setCollection = (e: any) => {
if (e?.__isNew__) e.value = null;
diff --git a/components/ModalContent/PreservedFormatsModal.tsx b/components/ModalContent/PreservedFormatsModal.tsx
index 30bd7b64..31620130 100644
--- a/components/ModalContent/PreservedFormatsModal.tsx
+++ b/components/ModalContent/PreservedFormatsModal.tsx
@@ -30,7 +30,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {
const { t } = useTranslation();
const session = useSession();
const { getLink } = useLinkStore();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const [link, setLink] =
useState<LinkIncludingShortenedCollectionAndTags>(activeLink);
const router = useRouter();
diff --git a/components/ModalContent/UploadFileModal.tsx b/components/ModalContent/UploadFileModal.tsx
index 8cd28075..74a8d905 100644
--- a/components/ModalContent/UploadFileModal.tsx
+++ b/components/ModalContent/UploadFileModal.tsx
@@ -49,7 +49,7 @@ export default function UploadFileModal({ onClose }: Props) {
const [submitLoader, setSubmitLoader] = useState(false);
const [optionsExpanded, setOptionsExpanded] = useState(false);
const router = useRouter();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
const setCollection = (e: any) => {
if (e?.__isNew__) e.value = null;
diff --git a/components/ProfileDropdown.tsx b/components/ProfileDropdown.tsx
index 2f262c25..4927517a 100644
--- a/components/ProfileDropdown.tsx
+++ b/components/ProfileDropdown.tsx
@@ -9,7 +9,7 @@ import { useUser } from "@/hooks/store/user";
export default function ProfileDropdown() {
const { t } = useTranslation();
const { settings, updateSettings } = useLocalSettingsStore();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const isAdmin = user.id === Number(process.env.NEXT_PUBLIC_ADMIN || 1);
diff --git a/components/ReadableView.tsx b/components/ReadableView.tsx
index 70e21fe4..da73b018 100644
--- a/components/ReadableView.tsx
+++ b/components/ReadableView.tsx
@@ -46,7 +46,7 @@ export default function ReadableView({ link }: Props) {
const router = useRouter();
const { getLink } = useLinkStore();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
const collection = useMemo(() => {
return collections.find(
diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx
index 43485712..540d0678 100644
--- a/components/Sidebar.tsx
+++ b/components/Sidebar.tsx
@@ -22,9 +22,9 @@ export default function Sidebar({ className }: { className?: string }) {
}
);
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
- const { data: tags = [] } = useTags();
+ const { data: tags } = useTags();
const [active, setActive] = useState("");
const router = useRouter();
diff --git a/hooks/store/collections.tsx b/hooks/store/collections.tsx
index fe79d1e0..932bb51d 100644
--- a/hooks/store/collections.tsx
+++ b/hooks/store/collections.tsx
@@ -11,6 +11,7 @@ const useCollections = () => {
const data = await response.json();
return data.response;
},
+ initialData: [],
});
};
diff --git a/hooks/store/tags.tsx b/hooks/store/tags.tsx
index c9738fe6..df51829e 100644
--- a/hooks/store/tags.tsx
+++ b/hooks/store/tags.tsx
@@ -13,6 +13,7 @@ const useTags = () => {
const data = await response.json();
return data.response;
},
+ initialData: [],
});
};
diff --git a/hooks/store/tokens.tsx b/hooks/store/tokens.tsx
index 18bcd9d3..20bef188 100644
--- a/hooks/store/tokens.tsx
+++ b/hooks/store/tokens.tsx
@@ -14,6 +14,7 @@ const useTokens = () => {
const data = await response.json();
return data.response as AccessToken[];
},
+ initialData: [],
});
};
diff --git a/hooks/store/user.tsx b/hooks/store/user.tsx
index 881cf0a5..ca1c4339 100644
--- a/hooks/store/user.tsx
+++ b/hooks/store/user.tsx
@@ -19,6 +19,7 @@ const useUser = () => {
return data.response;
},
enabled: !!userId,
+ initialData: {},
});
};
diff --git a/hooks/useCollectivePermissions.ts b/hooks/useCollectivePermissions.ts
index e093b645..b79cd4d1 100644
--- a/hooks/useCollectivePermissions.ts
+++ b/hooks/useCollectivePermissions.ts
@@ -4,9 +4,9 @@ import { useCollections } from "./store/collections";
import { useUser } from "./store/user";
export default function useCollectivePermissions(collectionIds: number[]) {
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const [permissions, setPermissions] = useState<Member | true>();
useEffect(() => {
diff --git a/hooks/useInitialData.tsx b/hooks/useInitialData.tsx
index fab5241b..73e0096e 100644
--- a/hooks/useInitialData.tsx
+++ b/hooks/useInitialData.tsx
@@ -6,7 +6,7 @@ import { useUser } from "./store/user";
export default function useInitialData() {
const { status, data } = useSession();
// const { setLinks } = useLinkStore();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const { setSettings } = useLocalSettingsStore();
useEffect(() => {
diff --git a/hooks/usePermissions.tsx b/hooks/usePermissions.tsx
index 7b6725ab..7625b49f 100644
--- a/hooks/usePermissions.tsx
+++ b/hooks/usePermissions.tsx
@@ -4,9 +4,9 @@ import { useCollections } from "./store/collections";
import { useUser } from "./store/user";
export default function usePermissions(collectionId: number) {
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const [permissions, setPermissions] = useState<Member | true>();
useEffect(() => {
diff --git a/layouts/AuthRedirect.tsx b/layouts/AuthRedirect.tsx
index 821065a6..0d07aee9 100644
--- a/layouts/AuthRedirect.tsx
+++ b/layouts/AuthRedirect.tsx
@@ -14,7 +14,7 @@ export default function AuthRedirect({ children }: Props) {
const router = useRouter();
const { status } = useSession();
const [shouldRenderChildren, setShouldRenderChildren] = useState(false);
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
useInitialData();
diff --git a/pages/admin.tsx b/pages/admin.tsx
index df62ffe4..72d6f2bb 100644
--- a/pages/admin.tsx
+++ b/pages/admin.tsx
@@ -21,7 +21,7 @@ type UserModal = {
export default function Admin() {
const { t } = useTranslation();
- const { data: users = [] } = useUsers();
+ const { data: users } = useUsers();
const [searchQuery, setSearchQuery] = useState("");
const [filteredUsers, setFilteredUsers] = useState<User[]>();
diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx
index 0c7ad8e5..f226d2d4 100644
--- a/pages/collections/[id].tsx
+++ b/pages/collections/[id].tsx
@@ -34,7 +34,7 @@ export default function Index() {
const router = useRouter();
const { links } = useLinkStore();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
const [sortBy, setSortBy] = useState<Sort>(Sort.DateNewestFirst);
@@ -51,7 +51,7 @@ export default function Index() {
);
}, [router, collections]);
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
const [collectionOwner, setCollectionOwner] = useState({
id: null as unknown as number,
diff --git a/pages/collections/index.tsx b/pages/collections/index.tsx
index f57ddfc5..0bf2c7ec 100644
--- a/pages/collections/index.tsx
+++ b/pages/collections/index.tsx
@@ -13,7 +13,7 @@ import { useCollections } from "@/hooks/store/collections";
export default function Collections() {
const { t } = useTranslation();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
const [sortBy, setSortBy] = useState<Sort>(Sort.DateNewestFirst);
const [sortedCollections, setSortedCollections] = useState(collections);
diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx
index adfa163c..a609c6bd 100644
--- a/pages/dashboard.tsx
+++ b/pages/dashboard.tsx
@@ -22,9 +22,9 @@ import { useTags } from "@/hooks/store/tags";
export default function Dashboard() {
const { t } = useTranslation();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
const { links } = useLinkStore();
- const { data: tags = [] } = useTags();
+ const { data: tags } = useTags();
const [numberOfLinks, setNumberOfLinks] = useState(0);
diff --git a/pages/links/index.tsx b/pages/links/index.tsx
index 35c14889..15803249 100644
--- a/pages/links/index.tsx
+++ b/pages/links/index.tsx
@@ -1,5 +1,6 @@
import NoLinksFound from "@/components/NoLinksFound";
import useLinks from "@/hooks/useLinks";
+// import { useLinks } from "@/hooks/store/links";
import MainLayout from "@/layouts/MainLayout";
import useLinkStore from "@/store/links";
import React, { useEffect, useState } from "react";
@@ -15,6 +16,8 @@ import { useTranslation } from "next-i18next";
export default function Links() {
const { t } = useTranslation();
+
+ // const { data: links } = useLinks();
const { links } = useLinkStore();
const [viewMode, setViewMode] = useState<string>(
diff --git a/pages/public/collections/[id].tsx b/pages/public/collections/[id].tsx
index db06ec8e..632b8312 100644
--- a/pages/public/collections/[id].tsx
+++ b/pages/public/collections/[id].tsx
@@ -32,7 +32,7 @@ export default function PublicCollections() {
const { settings } = useLocalSettingsStore();
- const { data: collections = [] } = useCollections();
+ const { data: collections } = useCollections();
const router = useRouter();
diff --git a/pages/settings/access-tokens.tsx b/pages/settings/access-tokens.tsx
index 9e1cfd6f..91d17612 100644
--- a/pages/settings/access-tokens.tsx
+++ b/pages/settings/access-tokens.tsx
@@ -18,7 +18,7 @@ export default function AccessTokens() {
setRevokeTokenModal(true);
};
- const { data: tokens = [] } = useTokens();
+ const { data: tokens } = useTokens();
return (
<SettingsLayout>
diff --git a/pages/settings/account.tsx b/pages/settings/account.tsx
index 5c4b109b..c3925968 100644
--- a/pages/settings/account.tsx
+++ b/pages/settings/account.tsx
@@ -24,7 +24,7 @@ export default function Account() {
const [emailChangeVerificationModal, setEmailChangeVerificationModal] =
useState(false);
const [submitLoader, setSubmitLoader] = useState(false);
- const { data: account = [] } = useUser();
+ const { data: account } = useUser();
const updateUser = useUpdateUser();
const [user, setUser] = useState<AccountSettings>(
!objectIsEmpty(account)
diff --git a/pages/settings/password.tsx b/pages/settings/password.tsx
index d63daf4f..4b0d3e88 100644
--- a/pages/settings/password.tsx
+++ b/pages/settings/password.tsx
@@ -13,7 +13,7 @@ export default function Password() {
const [oldPassword, setOldPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const [submitLoader, setSubmitLoader] = useState(false);
- const { data: account = [] } = useUser();
+ const { data: account } = useUser();
const updateUser = useUpdateUser();
const submit = async () => {
diff --git a/pages/settings/preference.tsx b/pages/settings/preference.tsx
index 18baee74..2e33ca1d 100644
--- a/pages/settings/preference.tsx
+++ b/pages/settings/preference.tsx
@@ -13,7 +13,7 @@ export default function Appearance() {
const { t } = useTranslation();
const { updateSettings } = useLocalSettingsStore();
const [submitLoader, setSubmitLoader] = useState(false);
- const { data: account = [] } = useUser();
+ const { data: account } = useUser();
const updateUser = useUpdateUser();
const [user, setUser] = useState(account);
diff --git a/pages/subscribe.tsx b/pages/subscribe.tsx
index fb2ad3a5..fe8bfd25 100644
--- a/pages/subscribe.tsx
+++ b/pages/subscribe.tsx
@@ -20,7 +20,7 @@ export default function Subscribe() {
const router = useRouter();
- const { data: user = [] } = useUser();
+ const { data: user } = useUser();
useEffect(() => {
const hasInactiveSubscription =
diff --git a/pages/tags/[id].tsx b/pages/tags/[id].tsx
index 2467da64..92fffe74 100644
--- a/pages/tags/[id].tsx
+++ b/pages/tags/[id].tsx
@@ -21,7 +21,7 @@ export default function Index() {
const router = useRouter();
const { links } = useLinkStore();
- const { data: tags = [] } = useTags();
+ const { data: tags } = useTags();
const updateTag = useUpdateTag();
const removeTag = useRemoveTag();