From 76dc812655db3e8023acc89943581000cecb193b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Jan 2026 15:52:22 +0000 Subject: [PATCH] fix: add explicit type annotations to compose dialog components Fix TypeScript strict type checking errors: ## ComposeDialog - Add EventFactory type import - Add explicit type for factory parameter in hub.run callback - Add explicit types for event handler parameters - Add explicit types for map callback parameters - Fix onRemove callback to have explicit void return ## PowerTools - Remove unused imports (Image, Zap, Sparkles) - Add explicit types for Input onChange/onKeyDown handlers - Add explicit type for ProfileSearchResult in map callback ## RelaySelector - Remove unused imports (Badge, Check) - Add explicit types for Input onChange/onKeyDown handlers - Add explicit types for relay filter/map callbacks All type errors addressed while maintaining functionality. --- src/components/ComposeDialog.tsx | 22 ++++++++++++++-------- src/components/PowerTools.tsx | 14 +++++++++----- src/components/RelaySelector.tsx | 19 ++++++++++--------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/components/ComposeDialog.tsx b/src/components/ComposeDialog.tsx index 97f1495..507a290 100644 --- a/src/components/ComposeDialog.tsx +++ b/src/components/ComposeDialog.tsx @@ -28,6 +28,7 @@ import { getDisplayName } from "@/lib/nostr-utils"; import { useProfile } from "applesauce-react/hooks"; import { RelaySelector } from "@/components/RelaySelector"; import { PowerTools } from "@/components/PowerTools"; +import type { EventFactory } from "applesauce-core/event-factory"; export interface ComposeDialogProps { /** Whether dialog is open */ @@ -140,11 +141,13 @@ export function ComposeDialog({ } // Create and sign event - const event = await hub.run(async ({ factory }) => { - const unsigned = factory.event(kind, messageContent, tags); - const signed = await factory.sign(unsigned); - return signed; - }); + const event = await hub.run( + async ({ factory }: { factory: EventFactory }) => { + const unsigned = factory.event(kind, messageContent, tags); + const signed = await factory.sign(unsigned); + return signed; + }, + ); // Publish to selected relays await publishEventToRelays(event, selectedRelays); @@ -214,7 +217,7 @@ export function ComposeDialog({
setShowPreview(v === "preview")} + onValueChange={(v: string) => setShowPreview(v === "preview")} className="flex-1 flex flex-col" > {/* Tab Navigation */} @@ -268,11 +271,13 @@ export function ComposeDialog({ Additional Mentions
- {additionalMentions.map((pubkey) => ( + {additionalMentions.map((pubkey: string) => ( handleRemoveMention(pubkey)} + onRemove={() => { + handleRemoveMention(pubkey); + }} /> ))}
@@ -389,6 +394,7 @@ function MentionBadge({ {displayName} diff --git a/src/components/PowerTools.tsx b/src/components/PowerTools.tsx index 86c4f17..cc47265 100644 --- a/src/components/PowerTools.tsx +++ b/src/components/PowerTools.tsx @@ -6,7 +6,7 @@ import { } from "@/components/ui/popover"; import { Input } from "@/components/ui/input"; import { useState, useCallback } from "react"; -import { Hash, AtSign, Code, Link, Image, Zap, Sparkles } from "lucide-react"; +import { Hash, AtSign, Code, Link } from "lucide-react"; import { useProfileSearch } from "@/hooks/useProfileSearch"; import type { ProfileSearchResult } from "@/services/profile-search"; import { nip19 } from "nostr-tools"; @@ -94,8 +94,10 @@ export function PowerTools({ onInsert, onAddMention }: PowerToolsProps) { setHashtagInput(e.target.value)} - onKeyDown={(e) => { + onChange={(e: React.ChangeEvent) => + setHashtagInput(e.target.value) + } + onKeyDown={(e: React.KeyboardEvent) => { if (e.key === "Enter") { handleHashtagInsert(); } @@ -128,14 +130,16 @@ export function PowerTools({ onInsert, onAddMention }: PowerToolsProps) { handleMentionSearch(e.target.value)} + onChange={(e: React.ChangeEvent) => + handleMentionSearch(e.target.value) + } className="text-sm" /> {/* Results */} {mentionResults.length > 0 && (
- {mentionResults.map((result) => ( + {mentionResults.map((result: ProfileSearchResult) => (