From 1fd94d9a200a6112133c4e2a8ac90b9d3a1f474a Mon Sep 17 00:00:00 2001 From: "Konrad (PC)" Date: Wed, 18 Dec 2024 01:41:17 +0100 Subject: [PATCH] chore: solvro/config compliance --- src/app/news/components/post-attachments.tsx | 18 ++++++++++-------- src/app/news/components/post.tsx | 6 ++++-- src/app/news/components/share-button.tsx | 4 ++-- src/components/ui/button.tsx | 2 +- src/lib/types.ts | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/app/news/components/post-attachments.tsx b/src/app/news/components/post-attachments.tsx index 3b01582..a2eb0bd 100644 --- a/src/app/news/components/post-attachments.tsx +++ b/src/app/news/components/post-attachments.tsx @@ -1,10 +1,11 @@ "use client"; -import { Button } from "@/components/ui/button"; -import { FacebookAttachment } from "@/lib/types"; import Image from "next/image"; import { useState } from "react"; +import { Button } from "@/components/ui/button"; +import type { FacebookAttachment } from "@/lib/types"; + function PostAttachment({ attachment }: { attachment: FacebookAttachment }) { const [showSubAttachments, setShowSubAttachments] = useState(false); const hasSubAttachments = attachment.subattachments?.data != null; @@ -20,14 +21,15 @@ function PostAttachment({ attachment }: { attachment: FacebookAttachment }) { className="my-4" width={800} height={0} - // width={attachment.media.image.width} - // height={attachment.media.image.height} /> )} - {hasSubAttachments && ( + {/* @solvro/config forced me into doing !! on a boolean */} + {!!hasSubAttachments && ( @@ -41,7 +43,7 @@ export function PostAttachments({ }: { attachments: FacebookAttachment[]; }) { - return attachments.map((attachment, idx) => ( - + return attachments.map((attachment) => ( + )); } diff --git a/src/app/news/components/post.tsx b/src/app/news/components/post.tsx index 33cb246..f01f059 100644 --- a/src/app/news/components/post.tsx +++ b/src/app/news/components/post.tsx @@ -45,13 +45,15 @@ export function Post({

- {(post.message == null || post.message.trim() === "") && ( + {(post.message ?? "") || ( empty post )}

- {post.permalink_url && } + {post.permalink_url.length > 0 && ( + + )}
); diff --git a/src/app/news/components/share-button.tsx b/src/app/news/components/share-button.tsx index 4dc2890..5843bac 100644 --- a/src/app/news/components/share-button.tsx +++ b/src/app/news/components/share-button.tsx @@ -12,9 +12,9 @@ export function ShareButton({ link }: { link: string }) { async function handleClick() { setClicked(true); if ("clipboard" in navigator && "writeText" in navigator.clipboard) { - setCopyingFailed(true); - } else { await navigator.clipboard.writeText(link); + } else { + setCopyingFailed(true); } setTimeout(() => { setClicked(false); diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 6f3f86a..1655205 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -13,7 +13,7 @@ const buttonVariants = cva( default: "rounded-md text-sm h-8 px-3 md:rounded-xs md:border-2 md:text-base md:h-10 md:px-4 border-2 border-primary hover:text-primary bg-primary text-primary-foreground hover:bg-primary/90", destructive: - "px-3 border-2 border-destructive bg-destructive text-destructive-foreground hover:bg-destructive/90", + "h-10 px-3 border-2 border-destructive bg-destructive text-destructive-foreground hover:bg-destructive/90", outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground", secondary: diff --git a/src/lib/types.ts b/src/lib/types.ts index e56268c..f2d250f 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -60,7 +60,7 @@ export interface FacebookAttachment { src: string; }; }; - subattachments: FacebookAttachments; + subattachments?: FacebookAttachments; } /** A Facebook post as returned by the Facebook API. */