minor improvement
This commit is contained in:
parent
2993347dc7
commit
cbf93dcf06
|
@ -113,8 +113,7 @@ export default function LinkCard({ link, columns, editMode }: Props) {
|
||||||
const permissions = usePermissions(collection?.id as number);
|
const permissions = usePermissions(collection?.id as number);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const isPublicRoute = router.pathname.startsWith("/public") ? true : false;
|
||||||
let isPublic = router.pathname.startsWith("/public") ? true : undefined;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let interval: NodeJS.Timeout | null = null;
|
let interval: NodeJS.Timeout | null = null;
|
||||||
|
@ -125,7 +124,10 @@ export default function LinkCard({ link, columns, editMode }: Props) {
|
||||||
link.preview !== "unavailable"
|
link.preview !== "unavailable"
|
||||||
) {
|
) {
|
||||||
interval = setInterval(async () => {
|
interval = setInterval(async () => {
|
||||||
getLink.mutateAsync({ id: link.id as number, isPublicRoute: isPublic });
|
getLink.mutateAsync({
|
||||||
|
id: link.id as number,
|
||||||
|
isPublicRoute: isPublicRoute,
|
||||||
|
});
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,8 +148,6 @@ export default function LinkCard({ link, columns, editMode }: Props) {
|
||||||
editMode &&
|
editMode &&
|
||||||
(permissions === true || permissions?.canCreate || permissions?.canDelete);
|
(permissions === true || permissions?.canCreate || permissions?.canDelete);
|
||||||
|
|
||||||
const isPublicRoute = router.pathname.startsWith("/public") ? true : false;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
@ -220,7 +220,7 @@ export default function LinkCard({ link, columns, editMode }: Props) {
|
||||||
<hr className="divider mt-2 mb-1 last:hidden border-t border-neutral-content h-[1px]" />
|
<hr className="divider mt-2 mb-1 last:hidden border-t border-neutral-content h-[1px]" />
|
||||||
|
|
||||||
<div className="flex justify-between items-center text-xs text-neutral px-3 pb-1 gap-2">
|
<div className="flex justify-between items-center text-xs text-neutral px-3 pb-1 gap-2">
|
||||||
{show.collection && (
|
{show.collection && !isPublicRoute && (
|
||||||
<div className="cursor-pointer truncate">
|
<div className="cursor-pointer truncate">
|
||||||
<LinkCollection link={link} collection={collection} />
|
<LinkCollection link={link} collection={collection} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
} from "@/types/global";
|
} from "@/types/global";
|
||||||
import { IconWeight } from "@phosphor-icons/react";
|
import { IconWeight } from "@phosphor-icons/react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default function LinkCollection({
|
export default function LinkCollection({
|
||||||
|
@ -14,7 +15,11 @@ export default function LinkCollection({
|
||||||
link: LinkIncludingShortenedCollectionAndTags;
|
link: LinkIncludingShortenedCollectionAndTags;
|
||||||
collection: CollectionIncludingMembersAndLinkCount;
|
collection: CollectionIncludingMembersAndLinkCount;
|
||||||
}) {
|
}) {
|
||||||
return collection?.name ? (
|
const router = useRouter();
|
||||||
|
|
||||||
|
const isPublicRoute = router.pathname.startsWith("/public") ? true : false;
|
||||||
|
|
||||||
|
return !isPublicRoute && collection?.name ? (
|
||||||
<>
|
<>
|
||||||
<Link
|
<Link
|
||||||
href={`/collections/${link.collection.id}`}
|
href={`/collections/${link.collection.id}`}
|
||||||
|
@ -40,7 +45,5 @@ export default function LinkCollection({
|
||||||
<p className="truncate capitalize">{collection?.name}</p>
|
<p className="truncate capitalize">{collection?.name}</p>
|
||||||
</Link>
|
</Link>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : null;
|
||||||
<></>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ export default function LinkMasonry({ link, editMode, columns }: Props) {
|
||||||
<hr className="divider mt-2 mb-1 last:hidden border-t border-neutral-content h-[1px]" />
|
<hr className="divider mt-2 mb-1 last:hidden border-t border-neutral-content h-[1px]" />
|
||||||
|
|
||||||
<div className="flex flex-wrap justify-between items-center text-xs text-neutral px-3 pb-1 w-full gap-x-2">
|
<div className="flex flex-wrap justify-between items-center text-xs text-neutral px-3 pb-1 w-full gap-x-2">
|
||||||
{show.collection && (
|
{!isPublic && show.collection && (
|
||||||
<div className="cursor-pointer truncate">
|
<div className="cursor-pointer truncate">
|
||||||
<LinkCollection link={link} collection={collection} />
|
<LinkCollection link={link} collection={collection} />
|
||||||
</div>
|
</div>
|
||||||
|
|
Ŝarĝante…
Reference in New Issue