undo commit

This commit is contained in:
daniel31x13
2024-11-03 03:25:01 -05:00
parent aeafe6e15d
commit 9103f67db5
176 changed files with 9406 additions and 2367 deletions
+28 -30
View File
@@ -3,7 +3,6 @@ import { readabilityAvailable } from "@/lib/shared/getArchiveValidity";
import isValidUrl from "@/lib/shared/isValidUrl";
import {
ArchivedFormat,
CollectionIncludingMembersAndLinkCount,
LinkIncludingShortenedCollectionAndTags,
} from "@/types/global";
import ColorThief, { RGBColor } from "colorthief";
@@ -11,11 +10,11 @@ import DOMPurify from "dompurify";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/router";
import React, { useEffect, useMemo, useState } from "react";
import LinkActions from "./LinkViews/LinkComponents/LinkActions";
import React, { useEffect, useState } from "react";
import { useTranslation } from "next-i18next";
import { useCollections } from "@/hooks/store/collections";
import { useGetLink } from "@/hooks/store/links";
import { IconWeight } from "@phosphor-icons/react";
import Icon from "./Icon";
type LinkContent = {
title: string;
@@ -46,13 +45,6 @@ export default function ReadableView({ link }: Props) {
const router = useRouter();
const getLink = useGetLink();
const { data: collections = [] } = useCollections();
const collection = useMemo(() => {
return collections.find(
(e) => e.id === link.collection.id
) as CollectionIncludingMembersAndLinkCount;
}, [collections, link]);
useEffect(() => {
const fetchLinkContent = async () => {
@@ -73,9 +65,9 @@ export default function ReadableView({ link }: Props) {
}, [link]);
useEffect(() => {
if (link) getLink.mutateAsync(link?.id as number);
if (link) getLink.mutateAsync({ id: link.id as number });
let interval: any;
let interval: NodeJS.Timeout | null = null;
if (
link &&
(link?.image === "pending" ||
@@ -88,7 +80,10 @@ export default function ReadableView({ link }: Props) {
!link?.monolith)
) {
interval = setInterval(
() => getLink.mutateAsync(link.id as number),
() =>
getLink.mutateAsync({
id: link.id as number,
}),
5000
);
} else {
@@ -186,7 +181,7 @@ export default function ReadableView({ link }: Props) {
link?.name || link?.description || link?.url || ""
)}
</p>
{link?.url ? (
{link?.url && (
<Link
href={link?.url || ""}
title={link?.url}
@@ -195,11 +190,10 @@ export default function ReadableView({ link }: Props) {
>
<i className="bi-link-45deg"></i>
{isValidUrl(link?.url || "")
? new URL(link?.url as string).host
: undefined}
{isValidUrl(link?.url || "") &&
new URL(link?.url as string).host}
</Link>
) : undefined}
)}
</div>
</div>
@@ -208,10 +202,21 @@ export default function ReadableView({ link }: Props) {
href={`/collections/${link?.collection.id}`}
className="flex items-center gap-1 cursor-pointer hover:opacity-60 duration-100 mr-2 z-10"
>
<i
className="bi-folder-fill drop-shadow text-2xl"
style={{ color: link?.collection.color }}
></i>
{link.collection.icon ? (
<Icon
icon={link.collection.icon}
size={30}
weight={
(link.collection.iconWeight || "regular") as IconWeight
}
color={link.collection.color}
/>
) : (
<i
className="bi-folder-fill text-2xl"
style={{ color: link.collection.color }}
></i>
)}
<p
title={link?.collection.name}
className="text-lg truncate max-w-[12rem]"
@@ -243,13 +248,6 @@ export default function ReadableView({ link }: Props) {
{link?.name ? <p>{unescapeString(link?.description)}</p> : undefined}
</div>
<LinkActions
link={link}
collection={collection}
position="top-3 right-3"
alignToTop
/>
</div>
<div className="flex flex-col gap-5 h-full">