mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 08:23:35 +00:00
change var names, remove unused, change component to pure style
This commit is contained in:
1 parent
b132e4847d
commit
51be437219
4 files changed
+32
-61
No files matched your search
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -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>
|
||||
|
||||
@@ -28,8 +28,8 @@ interface LastSyncData {
|
||||
}
|
||||
|
||||
interface SubscriptionStatus {
|
||||
nip4: boolean;
|
||||
nip17: boolean;
|
||||
isNIP4Connected: boolean;
|
||||
isNIP17Connected: boolean;
|
||||
}
|
||||
|
||||
interface ScanProgress {
|
||||
@@ -181,8 +181,8 @@ export function DMProvider({ children, enableNIP17 = true }: DMProviderProps) {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [loadingPhase, setLoadingPhase] = useState<LoadingPhase>(LOADING_PHASES.IDLE);
|
||||
const [subscriptions, setSubscriptions] = useState<SubscriptionStatus>({
|
||||
nip4: false,
|
||||
nip17: false
|
||||
isNIP4Connected: false,
|
||||
isNIP17Connected: false
|
||||
});
|
||||
const [hasInitialLoadCompleted, setHasInitialLoadCompleted] = useState(false);
|
||||
const [shouldSaveImmediately, setShouldSaveImmediately] = useState(false);
|
||||
@@ -797,10 +797,10 @@ export function DMProvider({ children, enableNIP17 = true }: DMProviderProps) {
|
||||
}
|
||||
};
|
||||
|
||||
setSubscriptions(prev => ({ ...prev, nip4: true }));
|
||||
setSubscriptions(prev => ({ ...prev, isNIP4Connected: true }));
|
||||
} catch (error) {
|
||||
console.error('[DM] Failed to start NIP-4 subscription:', error);
|
||||
setSubscriptions(prev => ({ ...prev, nip4: false }));
|
||||
setSubscriptions(prev => ({ ...prev, isNIP4Connected: false }));
|
||||
}
|
||||
}, [user, nostr, lastSync.nip4, processIncomingNIP4Message]);
|
||||
|
||||
@@ -848,10 +848,10 @@ export function DMProvider({ children, enableNIP17 = true }: DMProviderProps) {
|
||||
}
|
||||
};
|
||||
|
||||
setSubscriptions(prev => ({ ...prev, nip17: true }));
|
||||
setSubscriptions(prev => ({ ...prev, isNIP17Connected: true }));
|
||||
} catch (error) {
|
||||
console.error('[DM] Failed to start NIP-17 subscription:', error);
|
||||
setSubscriptions(prev => ({ ...prev, nip17: false }));
|
||||
setSubscriptions(prev => ({ ...prev, isNIP17Connected: false }));
|
||||
}
|
||||
}, [user, nostr, lastSync.nip17, enableNIP17, processIncomingNIP17Message]);
|
||||
|
||||
@@ -929,7 +929,7 @@ export function DMProvider({ children, enableNIP17 = true }: DMProviderProps) {
|
||||
if (debouncedWriteRef.current) {
|
||||
clearTimeout(debouncedWriteRef.current);
|
||||
}
|
||||
setSubscriptions({ nip4: false, nip17: false });
|
||||
setSubscriptions({ isNIP4Connected: false, isNIP17Connected: false });
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in new issue
Block a user