Skip to content

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

Fix merge conflicts

Isaac Wise898b126231ac
diff --cc components/CollectionCard.tsx
index 208a7d58,432425c2..abcdfa43
--- a/components/CollectionCard.tsx
+++ b/components/CollectionCard.tsx
@@@ -14,15 -10,17 +13,16 @@@ import EditCollectionSharingModal from
import DeleteCollectionModal from "./ModalContent/DeleteCollectionModal";
import { dropdownTriggerer } from "@/lib/client/utils";
import { useTranslation } from "next-i18next";
+ import { useUser } from "@/hooks/store/user";
-type Props = {
+export default function CollectionCard({
+ collection,
+}: {
collection: CollectionIncludingMembersAndLinkCount;
- className?: string;
-};
-
-export default function CollectionCard({ collection, className }: Props) {
+}) {
const { t } = useTranslation();
const { settings } = useLocalSettingsStore();
- const { account } = useAccountStore();
+ const { data: user = {} } = useUser();
const formattedDate = new Date(collection.createdAt as string).toLocaleString(
"en-US",
@@@ -155,11 -162,11 +158,9 @@@
<Link
href={`/collections/${collection.id}`}
style={{
-- backgroundImage: `linear-gradient(45deg, ${collection.color}30 10%, ${
-- settings.theme === "dark" ? "oklch(var(--b2))" : "oklch(var(--b2))"
-- } 50%, ${
-- settings.theme === "dark" ? "oklch(var(--b2))" : "oklch(var(--b2))"
-- } 100%)`,
++ backgroundImage: `linear-gradient(45deg, ${collection.color}30 10%, ${settings.theme === "dark" ? "oklch(var(--b2))" : "oklch(var(--b2))"
++ } 50%, ${settings.theme === "dark" ? "oklch(var(--b2))" : "oklch(var(--b2))"
++ } 100%)`,
}}
className="card card-compact shadow-md hover:shadow-none duration-200 border border-neutral-content"
>
diff --cc components/LinkViews/LinkComponents/LinkActions.tsx
index 9660daa7,3abc06d8..ad7e48b1
--- a/components/LinkViews/LinkComponents/LinkActions.tsx
+++ b/components/LinkViews/LinkComponents/LinkActions.tsx
@@@ -180,13 -195,13 +195,13 @@@ export default function LinkActions(
onClose={() => setDeleteLinkModal(false)}
activeLink={link}
/>
- ) : undefined}
- {preservedFormatsModal ? (
+ )}
+ {preservedFormatsModal && (
<PreservedFormatsModal
onClose={() => setPreservedFormatsModal(false)}
- activeLink={link}
+ link={link}
/>
- ) : undefined}
+ )}
{/* {expandedLink ? (
<ExpandedLink onClose={() => setExpandedLink(false)} link={link} />
) : undefined} */}
diff --cc components/ModalContent/EditCollectionSharingModal.tsx
index d3b86277,f004af4e..5763b5d4
--- a/components/ModalContent/EditCollectionSharingModal.tsx
+++ b/components/ModalContent/EditCollectionSharingModal.tsx
@@@ -1,14 -1,8 +1,12 @@@
import React, { useEffect, useState } from "react";
import TextInput from "@/components/TextInput";
- import useCollectionStore from "@/store/collections";
import toast from "react-hot-toast";
-import { CollectionIncludingMembersAndLinkCount, Member } from "@/types/global";
+import {
+ AccountSettings,
+ CollectionIncludingMembersAndLinkCount,
+ Member,
+} from "@/types/global";
import getPublicUserData from "@/lib/client/getPublicUserData";
- import useAccountStore from "@/store/account";
import usePermissions from "@/hooks/usePermissions";
import ProfilePhoto from "../ProfilePhoto";
import addMemberToCollection from "@/lib/client/addMemberToCollection";
diff --cc components/ModalContent/PreservedFormatsModal.tsx
index 9f8fbd18,7cd1df0d..5f5333fb
--- a/components/ModalContent/PreservedFormatsModal.tsx
+++ b/components/ModalContent/PreservedFormatsModal.tsx
@@@ -93,13 -96,10 +91,10 @@@ export default function PreservedFormat
useEffect(() => {
(async () => {
- const data = await getLink(link.id as number, isPublic);
- setLink(
- (data as any).response as LinkIncludingShortenedCollectionAndTags
- );
+ await getLink.mutateAsync(link.id as number);
})();
- let interval: any;
+ let interval: NodeJS.Timeout | null = null;
if (!isReady()) {
interval = setInterval(async () => {
@@@ -145,9 -140,9 +135,9 @@@
<p className="text-xl font-thin">{t("preserved_formats")}</p>
<div className="divider mb-2 mt-1"></div>
{screenshotAvailable(link) ||
-- pdfAvailable(link) ||
-- readabilityAvailable(link) ||
-- monolithAvailable(link) ? (
++ pdfAvailable(link) ||
++ readabilityAvailable(link) ||
++ monolithAvailable(link) ? (
<p className="mb-3">{t("available_formats")}</p>
) : (
""
@@@ -159,12 -154,12 +149,12 @@@
name={t("webpage")}
icon={"bi-filetype-html"}
format={ArchivedFormat.monolith}
- activeLink={link}
+ link={link}
downloadable={true}
/>
- ) : undefined}
+ )}
- {screenshotAvailable(link) ? (
+ {screenshotAvailable(link) && (
<PreservedFormatRow
name={t("screenshot")}
icon={"bi-file-earmark-image"}
@@@ -173,29 -168,29 +163,29 @@@
? ArchivedFormat.png
: ArchivedFormat.jpeg
}
- activeLink={link}
+ link={link}
downloadable={true}
/>
- ) : undefined}
+ )}
- {pdfAvailable(link) ? (
+ {pdfAvailable(link) && (
<PreservedFormatRow
name={t("pdf")}
icon={"bi-file-earmark-pdf"}
format={ArchivedFormat.pdf}
- activeLink={link}
+ link={link}
downloadable={true}
/>
- ) : undefined}
+ )}
- {readabilityAvailable(link) ? (
+ {readabilityAvailable(link) && (
<PreservedFormatRow
name={t("readable")}
icon={"bi-file-earmark-text"}
format={ArchivedFormat.readability}
- activeLink={link}
+ link={link}
/>
- ) : undefined}
+ )}
{!isReady() && !atLeastOneFormatAvailable() ? (
<div className={`w-full h-full flex flex-col justify-center p-10`}>
@@@ -208,25 -203,22 +198,24 @@@
<p className="text-center text-2xl">{t("preservation_in_queue")}</p>
<p className="text-center text-lg">{t("check_back_later")}</p>
</div>
- ) : !isReady() && atLeastOneFormatAvailable() ? (
- <div className={`w-full h-full flex flex-col justify-center p-5`}>
- <BeatLoader
- color="oklch(var(--p))"
- className="mx-auto mb-3"
- size={20}
- />
- <p className="text-center">{t("there_are_more_formats")}</p>
- <p className="text-center text-sm">{t("check_back_later")}</p>
- </div>
- ) : undefined}
+ ) : (
+ !isReady() &&
+ atLeastOneFormatAvailable() && (
+ <div className={`w-full h-full flex flex-col justify-center p-5`}>
+ <BeatLoader
+ color="oklch(var(--p))"
+ className="mx-auto mb-3"
+ size={20}
+ />
+ <p className="text-center">{t("there_are_more_formats")}</p>
+ <p className="text-center text-sm">{t("check_back_later")}</p>
+ </div>
+ )
+ )}
<div
-- className={`flex flex-col sm:flex-row gap-3 items-center justify-center ${
-- isReady() ? "sm:mt " : ""
-- }`}
++ className={`flex flex-col sm:flex-row gap-3 items-center justify-center ${isReady() ? "sm:mt " : ""
++ }`}
>
<Link
href={`https://web.archive.org/web/${link?.url?.replace(
diff --cc components/PreserverdFormatRow.tsx
index 6125c505,e8ddbd13..542aa9ff
--- a/components/PreserverdFormatRow.tsx
+++ b/components/PreserverdFormatRow.tsx
@@@ -19,14 -18,11 +17,9 @@@ export default function PreservedFormat
name,
icon,
format,
- activeLink,
+ link,
downloadable,
}: Props) {
- const { getLink } = useLinkStore();
-
- const [link, setLink] =
- useState<LinkIncludingShortenedCollectionAndTags>(activeLink);
- const getLink = useGetLink();
--
const router = useRouter();
let isPublic = router.pathname.startsWith("/public") ? true : undefined;
@@@ -90,20 -61,19 +58,18 @@@
</div>
<div className="flex gap-1">
- {downloadable ||
- (false && (
- <div
- onClick={() => handleDownload()}
- className="btn btn-sm btn-square"
- >
- <i className="bi-cloud-arrow-down text-xl text-neutral" />
- </div>
- ))}
+ {downloadable || false ? (
+ <div
+ onClick={() => handleDownload()}
+ className="btn btn-sm btn-square"
+ >
+ <i className="bi-cloud-arrow-down text-xl text-neutral" />
+ </div>
+ ) : undefined}
<Link
-- href={`${
-- isPublic ? "/public" : ""
-- }/preserved/${link?.id}?format=${format}`}
++ href={`${isPublic ? "/public" : ""
++ }/preserved/${link?.id}?format=${format}`}
target="_blank"
className="btn btn-sm btn-square"
>
@@@ -112,4 -82,4 +78,4 @@@
</div>
</div>
);
--}
++}
diff --cc components/ReadableView.tsx
index 5843b720,801e9c1a..073e8797
--- a/components/ReadableView.tsx
+++ b/components/ReadableView.tsx
@@@ -73,9 -73,9 +73,9 @@@ export default function ReadableView({
}, [link]);
useEffect(() => {
- if (link) getLink(link?.id as number);
+ if (link) getLink.mutateAsync(link?.id as number);
- let interval: any;
+ let interval: NodeJS.Timeout | null = null;
if (
link &&
(link?.image === "pending" ||
diff --cc pages/collections/[id].tsx
index b3741de5,f8e24b3c..4d7fc208
--- a/pages/collections/[id].tsx
+++ b/pages/collections/[id].tsx
@@@ -1,7 -1,4 +1,5 @@@
- import useCollectionStore from "@/store/collections";
- import useLinkStore from "@/store/links";
import {
+ AccountSettings,
CollectionIncludingMembersAndLinkCount,
Sort,
ViewMode,
@@@ -52,11 -52,17 +53,11 @@@ export default function Index()
);
}, [router, collections]);
- const { account } = useAccountStore();
+ const { data: user = {} } = useUser();
- const [collectionOwner, setCollectionOwner] = useState({
- id: null as unknown as number,
- name: "",
- username: "",
- image: "",
- archiveAsScreenshot: undefined as unknown as boolean,
- archiveAsMonolith: undefined as unknown as boolean,
- archiveAsPDF: undefined as unknown as boolean,
- });
+ const [collectionOwner, setCollectionOwner] = useState<
+ Partial<AccountSettings>
+ >({});
useEffect(() => {
const fetchOwner = async () => {
@@@ -110,9 -107,9 +102,8 @@@
<div
className="h-[60rem] p-5 flex gap-3 flex-col"
style={{
-- backgroundImage: `linear-gradient(${activeCollection?.color}20 10%, ${
-- settings.theme === "dark" ? "#262626" : "#f3f4f6"
-- } 13rem, ${settings.theme === "dark" ? "#171717" : "#ffffff"} 100%)`,
++ backgroundImage: `linear-gradient(${activeCollection?.color}20 10%, ${settings.theme === "dark" ? "#262626" : "#f3f4f6"
++ } 13rem, ${settings.theme === "dark" ? "#171717" : "#ffffff"} 100%)`,
}}
>
{activeCollection && (
@@@ -236,20 -237,20 +231,20 @@@
<p className="text-neutral text-sm">
{activeCollection.members.length > 0 &&
-- activeCollection.members.length === 1
++ activeCollection.members.length === 1
? t("by_author_and_other", {
++ author: collectionOwner.name,
++ count: activeCollection.members.length,
++ })
++ : activeCollection.members.length > 0 &&
++ activeCollection.members.length !== 1
++ ? t("by_author_and_others", {
author: collectionOwner.name,
count: activeCollection.members.length,
})
-- : activeCollection.members.length > 0 &&
-- activeCollection.members.length !== 1
-- ? t("by_author_and_others", {
-- author: collectionOwner.name,
-- count: activeCollection.members.length,
-- })
: t("by_author", {
-- author: collectionOwner.name,
-- })}
++ author: collectionOwner.name,
++ })}
</p>
</div>
</div>
@@@ -294,15 -295,15 +289,15 @@@
setSortBy={setSortBy}
editMode={
permissions === true ||
-- permissions?.canUpdate ||
-- permissions?.canDelete
++ permissions?.canUpdate ||
++ permissions?.canDelete
? editMode
: undefined
}
setEditMode={
permissions === true ||
-- permissions?.canUpdate ||
-- permissions?.canDelete
++ permissions?.canUpdate ||
++ permissions?.canDelete
? setEditMode
: undefined
}
@@@ -310,11 -311,11 +305,11 @@@
<p>
{activeCollection?._count?.links === 1
? t("showing_count_result", {
-- count: activeCollection?._count?.links,
-- })
++ count: activeCollection?._count?.links,
++ })
: t("showing_count_results", {
-- count: activeCollection?._count?.links,
-- })}
++ count: activeCollection?._count?.links,
++ })}
</p>
</LinkListOptions>
diff --cc pages/public/collections/[id].tsx
index 4eb0b8de,ab7fd426..27709497
--- a/pages/public/collections/[id].tsx
+++ b/pages/public/collections/[id].tsx
@@@ -86,31 -95,20 +90,30 @@@ export default function PublicCollectio
const [editCollectionSharingModal, setEditCollectionSharingModal] =
useState(false);
- const [viewMode, setViewMode] = useState<string>(
- localStorage.getItem("viewMode") || ViewMode.Card
+ const [viewMode, setViewMode] = useState<ViewMode>(
+ (localStorage.getItem("viewMode") as ViewMode) || ViewMode.Card
);
- return collection ? (
+ const linkView = {
+ [ViewMode.Card]: CardView,
+ [ViewMode.List]: ListView,
+ [ViewMode.Masonry]: MasonryView,
+ };
+
+ // @ts-ignore
+ const LinkComponent = linkView[viewMode];
+
+ if (!collection) return null;
+
+ return (
<div
className="h-96"
style={{
-- backgroundImage: `linear-gradient(${collection?.color}30 10%, ${
-- settings.theme === "dark" ? "#262626" : "#f3f4f6"
-- } 13rem, ${settings.theme === "dark" ? "#171717" : "#ffffff"} 100%)`,
++ backgroundImage: `linear-gradient(${collection?.color}30 10%, ${settings.theme === "dark" ? "#262626" : "#f3f4f6"
++ } 13rem, ${settings.theme === "dark" ? "#171717" : "#ffffff"} 100%)`,
}}
>
- {collection ? (
+ {collection && (
<Head>
<title>{collection.name} | Linkwarden</title>
<meta
@@@ -178,20 -176,20 +181,20 @@@
<p className="text-neutral text-sm">
{collection.members.length > 0 &&
-- collection.members.length === 1
++ collection.members.length === 1
? t("by_author_and_other", {
++ author: collectionOwner.name,
++ count: collection.members.length,
++ })
++ : collection.members.length > 0 &&
++ collection.members.length !== 1
++ ? t("by_author_and_others", {
author: collectionOwner.name,
count: collection.members.length,
})
-- : collection.members.length > 0 &&
-- collection.members.length !== 1
-- ? t("by_author_and_others", {
-- author: collectionOwner.name,
-- count: collection.members.length,
-- })
: t("by_author", {
-- author: collectionOwner.name,
-- })}
++ author: collectionOwner.name,
++ })}
</p>
</div>
</div>
@@@ -215,11 -213,11 +218,11 @@@
placeholder={
collection._count?.links === 1
? t("search_count_link", {
-- count: collection._count?.links,
-- })
++ count: collection._count?.links,
++ })
: t("search_count_links", {
-- count: collection._count?.links,
-- })
++ count: collection._count?.links,
++ })
}
/>
</LinkListOptions>
diff --cc pages/settings/account.tsx
index 0939d124,2feddb30..488437fe
--- a/pages/settings/account.tsx
+++ b/pages/settings/account.tsx
@@@ -1,5 -1,4 +1,4 @@@
-import { useState, useEffect } from "react";
+import { useState, useEffect, ChangeEvent } from "react";
- import useAccountStore from "@/store/account";
import { AccountSettings } from "@/types/global";
import { toast } from "react-hot-toast";
import SettingsLayout from "@/layouts/SettingsLayout";
@@@ -29,19 -30,19 +30,19 @@@ export default function Account()
!objectIsEmpty(account)
? account
: ({
-- // @ts-ignore
-- id: null,
-- name: "",
-- username: "",
-- email: "",
-- emailVerified: null,
-- password: undefined,
-- image: "",
-- isPrivate: true,
-- // @ts-ignore
-- createdAt: null,
-- whitelistedUsers: [],
-- } as unknown as AccountSettings)
++ // @ts-ignore
++ id: null,
++ name: "",
++ username: "",
++ email: "",
++ emailVerified: null,
++ password: undefined,
++ image: "",
++ isPrivate: true,
++ // @ts-ignore
++ createdAt: null,
++ whitelistedUsers: [],
++ } as unknown as AccountSettings)
);
const { t } = useTranslation();
diff --cc types/global.ts
index 3a7e6968,1cbbde8a..cc3d962b
--- a/types/global.ts
+++ b/types/global.ts
@@@ -81,10 -80,8 +80,10 @@@ export enum Sort
DescriptionZA,
}
+export type Order = { [key: string]: "asc" | "desc" };
+
export type LinkRequestQuery = {
- sort: Sort;
+ sort?: Sort;
cursor?: number;
collectionId?: number;
tagId?: number;