From 543eda02eebcc4b3926bb8e1676743dbdee507d7 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 2 Mar 2026 10:24:32 -0600 Subject: [PATCH] Fix linter errors: conditional hook, unused vars/imports, and unstable deps --- src/components/ComposeBox.tsx | 2 +- src/components/EmojiPicker.tsx | 4 +++- src/components/QuickReactMenu.tsx | 3 ++- src/components/SidebarMoreMenu.tsx | 10 +++++----- src/pages/PhotosFeedPage.tsx | 18 ++++-------------- src/pages/VideosFeedPage.tsx | 2 +- src/pages/VinesFeedPage.tsx | 5 +---- 7 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/components/ComposeBox.tsx b/src/components/ComposeBox.tsx index 6b67a2bc..f6f7aad2 100644 --- a/src/components/ComposeBox.tsx +++ b/src/components/ComposeBox.tsx @@ -164,7 +164,7 @@ export function ComposeBox({ const { feedSettings } = useFeedSettings(); const customEmojisEnabled = feedSettings.showCustomEmojis !== false; const { emojis: allCustomEmojis } = useCustomEmojis(); - const customEmojis = customEmojisEnabled ? allCustomEmojis : []; + const customEmojis = useMemo(() => customEmojisEnabled ? allCustomEmojis : [], [customEmojisEnabled, allCustomEmojis]); const queryClient = useQueryClient(); const { toast } = useToast(); diff --git a/src/components/EmojiPicker.tsx b/src/components/EmojiPicker.tsx index 6ed2de63..4a9e2783 100644 --- a/src/components/EmojiPicker.tsx +++ b/src/components/EmojiPicker.tsx @@ -55,7 +55,8 @@ export function EmojiPicker({ onSelect, customEmojis }: EmojiPickerProps) { // Custom themes set class="custom" on (not .dark), so we can't // rely on the dark class. Instead, check the actual computed background // luminance to determine if the current theme is visually dark. - void theme; // depend on theme for reactivity when it changes + // `theme` is intentionally in the dependency array to trigger recomputation + // when the theme changes, even though we read from CSS vars instead. const resolvedTheme = useMemo(() => { if (typeof document === 'undefined') return 'light'; const bg = getComputedStyle(document.documentElement).getPropertyValue('--background').trim(); @@ -67,6 +68,7 @@ export function EmojiPicker({ onSelect, customEmojis }: EmojiPickerProps) { return lightness < 50 ? 'dark' : 'light'; } return 'light'; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [theme]) as 'dark' | 'light'; const onSelectRef = useRef(onSelect); diff --git a/src/components/QuickReactMenu.tsx b/src/components/QuickReactMenu.tsx index 135bddae..da15b65a 100644 --- a/src/components/QuickReactMenu.tsx +++ b/src/components/QuickReactMenu.tsx @@ -48,7 +48,8 @@ export function QuickReactMenu({ const { trackEmojiUsage, getTopEmojis } = useEmojiUsage(); const { feedSettings } = useFeedSettings(); const { emojis: allCustomEmojis } = useCustomEmojis(); - const customEmojis = feedSettings.showCustomEmojis !== false ? allCustomEmojis : []; + const customEmojisEnabled = feedSettings.showCustomEmojis !== false; + const customEmojis = useMemo(() => customEmojisEnabled ? allCustomEmojis : [], [customEmojisEnabled, allCustomEmojis]); const [showFullPicker, setShowFullPicker] = useState(false); const [selectedEmoji, setSelectedEmoji] = useState(null); diff --git a/src/components/SidebarMoreMenu.tsx b/src/components/SidebarMoreMenu.tsx index 2e12e8fd..f01dc8fb 100644 --- a/src/components/SidebarMoreMenu.tsx +++ b/src/components/SidebarMoreMenu.tsx @@ -22,6 +22,11 @@ interface SidebarMoreMenuProps { export function SidebarMoreMenu({ editing, hiddenItems, onDoneEditing, onStartEditing, onAdd, onAddDivider, onNavigate, open, onOpenChange, }: SidebarMoreMenuProps) { + const [query, setQuery] = useState(''); + const filtered = hiddenItems.filter((item) => + item.label.toLowerCase().includes(query.toLowerCase()) + ); + if (editing) { return (
@@ -43,11 +48,6 @@ export function SidebarMoreMenu({ ); } - const [query, setQuery] = useState(''); - const filtered = hiddenItems.filter((item) => - item.label.toLowerCase().includes(query.toLowerCase()) - ); - return ( { onOpenChange(o); if (!o) setQuery(''); }}> diff --git a/src/pages/PhotosFeedPage.tsx b/src/pages/PhotosFeedPage.tsx index 0ba5d956..ec89a9b7 100644 --- a/src/pages/PhotosFeedPage.tsx +++ b/src/pages/PhotosFeedPage.tsx @@ -32,19 +32,18 @@ import { cn } from '@/lib/utils'; import type { FeedItem } from '@/lib/feedUtils'; import { useAuthor } from '@/hooks/useAuthor'; import { useProfileUrl } from '@/hooks/useProfileUrl'; -import { useOpenPost } from '@/hooks/useOpenPost'; + import { useBlossomFallback } from '@/hooks/useBlossomFallback'; import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'; import { getDisplayName } from '@/lib/getDisplayName'; import { genUserName } from '@/lib/genUserName'; -import { timeAgo } from '@/lib/timeAgo'; + import { canZap } from '@/lib/canZap'; import { ZapDialog } from '@/components/ZapDialog'; import { RepostMenu } from '@/components/RepostMenu'; import { NoteMoreMenu } from '@/components/NoteMoreMenu'; import { RepostIcon } from '@/components/icons/RepostIcon'; import { ProfileHoverCard } from '@/components/ProfileHoverCard'; -import { nip19 } from 'nostr-tools'; const PHOTO_KIND = 20; const photosDef = getExtraKindDef('photos')!; @@ -185,15 +184,6 @@ function formatSats(sats: number): string { return sats.toString(); } -function encodeEvent(event: NostrEvent): string { - if (event.kind >= 30000 && event.kind < 40000) { - const d = event.tags.find(([n]) => n === 'd')?.[1]; - if (d) return nip19.naddrEncode({ kind: event.kind, pubkey: event.pubkey, identifier: d }); - } - return nip19.neventEncode({ id: event.id, author: event.pubkey }); -} - - /** * Vine-style photo card for the overlay: image fills all available height, @@ -205,7 +195,7 @@ function PhotoCard({ event, onCommentClick }: { event: NostrEvent; onCommentClic const metadata = author.data?.metadata; const displayName = getDisplayName(metadata, event.pubkey) ?? genUserName(event.pubkey); const profileUrl = useProfileUrl(event.pubkey, metadata); - const encodedId = useMemo(() => encodeEvent(event), [event]); + const { data: stats } = useEventStats(event.id); const [moreMenuOpen, setMoreMenuOpen] = useState(false); const canZapAuthor = user && canZap(metadata); @@ -214,7 +204,7 @@ function PhotoCard({ event, onCommentClick }: { event: NostrEvent; onCommentClic const [photoIndex, setPhotoIndex] = useState(0); const currentPhoto = photos[photoIndex] ?? photos[0]; - const { onClick: openPost } = useOpenPost(`/${encodedId}`); + if (!currentPhoto) return null; diff --git a/src/pages/VideosFeedPage.tsx b/src/pages/VideosFeedPage.tsx index da382d2e..7f2ec203 100644 --- a/src/pages/VideosFeedPage.tsx +++ b/src/pages/VideosFeedPage.tsx @@ -35,7 +35,7 @@ import { useMuteList } from '@/hooks/useMuteList'; import { isEventMuted } from '@/lib/muteHelpers'; import { getDisplayName } from '@/lib/getDisplayName'; import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'; -import { Badge } from '@/components/ui/badge'; + import { Skeleton } from '@/components/ui/skeleton'; import { KindInfoButton } from '@/components/KindInfoButton'; import { useVideoThumbnail } from '@/components/VideoPlayer'; diff --git a/src/pages/VinesFeedPage.tsx b/src/pages/VinesFeedPage.tsx index 3fd4b908..8e14af6f 100644 --- a/src/pages/VinesFeedPage.tsx +++ b/src/pages/VinesFeedPage.tsx @@ -15,7 +15,7 @@ import { MoreHorizontal, Play, Heart, - ChevronLeft, + } from 'lucide-react'; import type { NostrEvent } from '@nostrify/nostrify'; @@ -40,12 +40,10 @@ import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'; import { Skeleton } from '@/components/ui/skeleton'; -import { ReplyComposeModal } from '@/components/ReplyComposeModal'; import { CommentsSheet } from '@/components/CommentsSheet'; import { getDisplayName } from '@/lib/getDisplayName'; import { useProfileUrl } from '@/hooks/useProfileUrl'; import { canZap } from '@/lib/canZap'; -import { timeAgo } from '@/lib/timeAgo'; import { cn } from '@/lib/utils'; const VINE_KIND = 34236; @@ -448,7 +446,6 @@ export function VinesFeedPage() { const { events, isLoading } = useVinesFeed(tab); const [activeIndex, setActiveIndex] = useState(0); const [commentsOpen, setCommentsOpen] = useState(false); - const [replyOpen, setReplyOpen] = useState(false); const containerRef = useRef(null); const handleCommentClick = useCallback(() => {