diff --git a/components/CollectionCard.tsx b/components/CollectionCard.tsx index bb3a3dd..9a47f6e 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 75b12cc..df85572 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 81bef39..24700c2 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 efd246b..c9d3c27 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([]); diff --git a/components/LinkViews/LinkCard.tsx b/components/LinkViews/LinkCard.tsx index e28ee9c..d6df2b3 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 0a3775e..430577b 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 9755ad9..5711838 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 ca05f1a..35cbaa9 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 158f817..b1af6a4 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 5164789..16c8489 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 30bd7b6..3162013 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(activeLink); const router = useRouter(); diff --git a/components/ModalContent/UploadFileModal.tsx b/components/ModalContent/UploadFileModal.tsx index 8cd2807..74a8d90 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 2f262c2..4927517 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 70e21fe..da73b01 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 4348571..540d067 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 fe79d1e..932bb51 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 c9738fe..df51829 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 18bcd9d..20bef18 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 881cf0a..ca1c433 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 e093b64..b79cd4d 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(); useEffect(() => { diff --git a/hooks/useInitialData.tsx b/hooks/useInitialData.tsx index fab5241..73e0096 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 7b6725a..7625b49 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(); useEffect(() => { diff --git a/layouts/AuthRedirect.tsx b/layouts/AuthRedirect.tsx index 821065a..0d07aee 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 df62ffe..72d6f2b 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(); diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx index 0c7ad8e..f226d2d 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.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 f57ddfc..0bf2c7e 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.DateNewestFirst); const [sortedCollections, setSortedCollections] = useState(collections); diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx index adfa163..a609c6b 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 35c1488..1580324 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( diff --git a/pages/public/collections/[id].tsx b/pages/public/collections/[id].tsx index db06ec8..632b831 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 9e1cfd6..91d1761 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 ( diff --git a/pages/settings/account.tsx b/pages/settings/account.tsx index 5c4b109..c392596 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( !objectIsEmpty(account) diff --git a/pages/settings/password.tsx b/pages/settings/password.tsx index d63daf4..4b0d3e8 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 18baee7..2e33ca1 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 fb2ad3a..fe8bfd2 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 2467da6..92fffe7 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();