Fix linter errors: conditional hook, unused vars/imports, and unstable deps
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ export function EmojiPicker({ onSelect, customEmojis }: EmojiPickerProps) {
|
||||
// Custom themes set class="custom" on <html> (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);
|
||||
|
||||
|
||||
@@ -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<string | null>(null);
|
||||
|
||||
@@ -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 (
|
||||
<div className="flex flex-col gap-0.5">
|
||||
@@ -43,11 +48,6 @@ export function SidebarMoreMenu({
|
||||
);
|
||||
}
|
||||
|
||||
const [query, setQuery] = useState('');
|
||||
const filtered = hiddenItems.filter((item) =>
|
||||
item.label.toLowerCase().includes(query.toLowerCase())
|
||||
);
|
||||
|
||||
return (
|
||||
<DropdownMenu open={open} onOpenChange={(o) => { onOpenChange(o); if (!o) setQuery(''); }}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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<HTMLDivElement>(null);
|
||||
|
||||
const handleCommentClick = useCallback(() => {
|
||||
|
||||
Reference in New Issue
Block a user