change var names, remove unused, change component to pure style

This commit is contained in:
sam committed 2025-10-18 18:25:46 +07:00
1 parent b132e4847d
commit 51be437219
4 files changed
+32 -61

No files matched your search

+9 -37
View File
@@ -9,7 +9,6 @@ import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Textarea } from '@/components/ui/textarea';
import { ScrollArea } from '@/components/ui/scroll-area';
import { Skeleton } from '@/components/ui/skeleton';
import { Badge } from '@/components/ui/badge';
import { ArrowLeft, Send, Loader2 } from 'lucide-react';
import { cn } from '@/lib/utils';
@@ -20,7 +19,7 @@ interface ChatAreaProps {
className?: string;
}
function MessageBubble({
const MessageBubble = ({
message,
isFromCurrentUser
}: {
@@ -32,7 +31,7 @@ function MessageBubble({
isSending?: boolean;
};
isFromCurrentUser: boolean;
}) {
}) => {
const formatTime = (timestamp: number) => {
const date = new Date(timestamp * 1000);
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
@@ -67,9 +66,9 @@ function MessageBubble({
</div>
</div>
);
}
};
function ChatHeader({ pubkey, onBack }: { pubkey: string; onBack?: () => void }) {
const ChatHeader = ({ pubkey, onBack }: { pubkey: string; onBack?: () => void }) => {
const author = useAuthor(pubkey);
const metadata = author.data?.metadata;
@@ -103,9 +102,9 @@ function ChatHeader({ pubkey, onBack }: { pubkey: string; onBack?: () => void })
</div>
</div>
);
}
};
function EmptyState() {
const EmptyState = () => {
return (
<div className="h-full flex items-center justify-center p-8">
<div className="text-center text-muted-foreground max-w-sm">
@@ -116,35 +115,9 @@ function EmptyState() {
</div>
</div>
);
}
};
function ChatAreaSkeleton() {
return (
<div className="h-full flex flex-col">
<div className="p-4 border-b flex items-center gap-3">
<Skeleton className="h-10 w-10 rounded-full" />
<div className="flex-1 space-y-2">
<Skeleton className="h-4 w-32" />
<Skeleton className="h-3 w-24" />
</div>
</div>
<div className="flex-1 p-4 space-y-4">
{[1, 2, 3].map((i) => (
<div key={i} className={cn("flex", i % 2 === 0 ? "justify-end" : "justify-start")}>
<Skeleton className="h-16 w-64 rounded-lg" />
</div>
))}
</div>
<div className="p-4 border-t">
<Skeleton className="h-20 w-full" />
</div>
</div>
);
}
export function ChatArea({ pubkey, onBack, className }: ChatAreaProps) {
export const ChatArea = ({ pubkey, onBack, className }: ChatAreaProps) => {
const { user } = useCurrentUser();
const { sendMessage, isNIP17Enabled } = useDMContext();
const { messages, totalCount } = useConversationMessages(pubkey || '');
@@ -268,5 +241,4 @@ export function ChatArea({ pubkey, onBack, className }: ChatAreaProps) {
</div>
</Card>
);
}
};
+7 -8
View File
@@ -14,7 +14,7 @@ interface ConversationListProps {
className?: string;
}
function ConversationItem({
const ConversationItem = ({
pubkey,
isSelected,
onClick,
@@ -28,7 +28,7 @@ function ConversationItem({
lastMessage: { decryptedContent?: string; error?: string } | null;
lastActivity: number;
hasNIP17Messages: boolean;
}) {
}) => {
const author = useAuthor(pubkey);
const metadata = author.data?.metadata;
@@ -88,9 +88,9 @@ function ConversationItem({
</div>
</button>
);
}
};
function ConversationListSkeleton() {
const ConversationListSkeleton = () => {
return (
<div className="space-y-2 p-4">
{[1, 2, 3, 4, 5].map((i) => (
@@ -107,9 +107,9 @@ function ConversationListSkeleton() {
))}
</div>
);
}
};
export function ConversationList({
export const ConversationList = ({
selectedPubkey,
onSelectConversation,
className
@@ -161,5 +161,4 @@ export function ConversationList({
</ScrollArea>
</Card>
);
}
};
+7 -7
View File
@@ -105,12 +105,12 @@ export const DMStatusInfo = ({ clearCache }: DMStatusInfoProps) => {
</Card>
{/* Scan Progress */}
{(scanProgress.nip4 || scanProgress.nip17) && (
{(scanProgress.nip4 !== null || scanProgress.nip17 !== null) && (
<Card>
<CardContent className="pt-6">
<div className="space-y-3">
<p className="text-sm font-medium">Scanning Messages</p>
{scanProgress.nip4 && (
{scanProgress.nip4 !== null && (
<div className="space-y-1">
<div className="flex items-center justify-between text-xs">
<span className="text-muted-foreground">NIP-4 (Legacy)</span>
@@ -119,7 +119,7 @@ export const DMStatusInfo = ({ clearCache }: DMStatusInfoProps) => {
<p className="text-xs text-muted-foreground">{scanProgress.nip4.status}</p>
</div>
)}
{scanProgress.nip17 && (
{scanProgress.nip17 !== null && (
<div className="space-y-1">
<div className="flex items-center justify-between text-xs">
<span className="text-muted-foreground">NIP-17 (Private)</span>
@@ -141,14 +141,14 @@ export const DMStatusInfo = ({ clearCache }: DMStatusInfoProps) => {
<div className="space-y-2">
<div className="flex items-center justify-between">
<span className="text-sm text-muted-foreground">NIP-4 (Legacy DMs)</span>
<Badge variant={subscriptions.nip4 ? 'default' : 'secondary'}>
{subscriptions.nip4 ? 'Connected' : 'Disconnected'}
<Badge variant={subscriptions.isNIP4Connected ? 'default' : 'secondary'}>
{subscriptions.isNIP4Connected ? 'Connected' : 'Disconnected'}
</Badge>
</div>
<div className="flex items-center justify-between">
<span className="text-sm text-muted-foreground">NIP-17 (Private DMs)</span>
<Badge variant={subscriptions.nip17 ? 'default' : 'secondary'}>
{subscriptions.nip17 ? 'Connected' : 'Disconnected'}
<Badge variant={subscriptions.isNIP17Connected ? 'default' : 'secondary'}>
{subscriptions.isNIP17Connected ? 'Connected' : 'Disconnected'}
</Badge>
</div>
</div>