mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-08 22:47:02 +02:00
fix: zap sender in compact zaps
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { memo, useCallback } from "react";
|
||||
import type { NostrEvent } from "@/types/nostr";
|
||||
import { kinds } from "nostr-tools";
|
||||
import { useGrimoire } from "@/core/state";
|
||||
import { formatTimestamp } from "@/hooks/useLocale";
|
||||
import { getTagValue } from "applesauce-core/helpers";
|
||||
import { getTagValue, getZapSender } from "applesauce-core/helpers";
|
||||
import { KindBadge } from "@/components/KindBadge";
|
||||
import { UserName } from "./UserName";
|
||||
import { compactRenderers, DefaultCompactPreview } from "./compact";
|
||||
@@ -77,10 +78,14 @@ export function CompactEventRow({ event }: CompactEventRowProps) {
|
||||
<KindBadge kind={event.kind} variant="compact" className="shrink-0" />
|
||||
|
||||
{/* Author */}
|
||||
<UserName
|
||||
pubkey={event.pubkey}
|
||||
className="text-sm shrink-0 max-w-[100px] truncate"
|
||||
/>
|
||||
{event.kind === kinds.Zap && getZapSender(event) ? (
|
||||
<UserName
|
||||
pubkey={getZapSender(event) as string}
|
||||
className="shrink-0 truncate"
|
||||
/>
|
||||
) : (
|
||||
<UserName pubkey={event.pubkey} className="shrink-0 truncate" />
|
||||
)}
|
||||
|
||||
{/* Kind-specific or default preview */}
|
||||
<div className="flex-1 min-w-0 truncate">
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
getZapRequest,
|
||||
} from "applesauce-core/helpers/zap";
|
||||
import { useNostrEvent } from "@/hooks/useNostrEvent";
|
||||
import { getContentPreview } from "./index";
|
||||
import { UserName } from "../UserName";
|
||||
import { RichText } from "../RichText";
|
||||
|
||||
@@ -41,9 +40,6 @@ export function ZapCompactPreview({ event }: { event: NostrEvent }) {
|
||||
return Math.floor(zapAmount / 1000);
|
||||
}, [zapAmount]);
|
||||
|
||||
// Get content preview
|
||||
const preview = zappedEvent ? getContentPreview(zappedEvent, 40) : null;
|
||||
|
||||
return (
|
||||
<span className="flex items-center gap-1 text-sm truncate">
|
||||
<Zap className="size-3 fill-yellow-500 text-yellow-500 shrink-0" />
|
||||
@@ -61,13 +57,10 @@ export function ZapCompactPreview({ event }: { event: NostrEvent }) {
|
||||
)}
|
||||
{zappedEvent && (
|
||||
<>
|
||||
<UserName
|
||||
pubkey={zappedEvent.pubkey}
|
||||
className="text-sm truncate line-clamp-1"
|
||||
/>
|
||||
<UserName pubkey={zappedEvent.pubkey} className="flex-1" />
|
||||
<span className="text-muted-foreground truncate line-clamp-1">
|
||||
<RichText
|
||||
content={preview || ""}
|
||||
event={zappedEvent}
|
||||
className="inline text-sm leading-none"
|
||||
options={{ showMedia: false, showEventEmbeds: false }}
|
||||
/>
|
||||
|
||||
@@ -301,10 +301,7 @@ export function BaseEventContainer({
|
||||
label?: string;
|
||||
};
|
||||
}) {
|
||||
// const { addWindow } = useGrimoire();
|
||||
const { locale } = useGrimoire();
|
||||
// const compactModeKinds = state.compactModeKinds || [];
|
||||
// const isCompact = compactModeKinds.includes(event.kind);
|
||||
|
||||
// Format relative time for display
|
||||
const relativeTime = formatTimestamp(
|
||||
@@ -323,59 +320,6 @@ export function BaseEventContainer({
|
||||
// Use author override if provided, otherwise use event author
|
||||
const displayPubkey = authorOverride?.pubkey || event.pubkey;
|
||||
|
||||
/*
|
||||
if (isCompact) {
|
||||
const reply = getEventReply(event);
|
||||
|
||||
const handleReplyClick = (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
if (!reply) return;
|
||||
|
||||
// Type guard to check if it's an AddressPointer (has 'kind' property)
|
||||
const pointer = reply.pointer;
|
||||
if ("kind" in pointer) {
|
||||
addWindow("open", { pointer: pointer });
|
||||
} else {
|
||||
addWindow("open", { pointer: { id: pointer.id } });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-row items-center gap-2 p-3 py-0">
|
||||
<EventAuthor pubkey={displayPubkey} className="" />
|
||||
{event.kind === kinds.Zap ? (
|
||||
<div className="flex items-center gap-1">
|
||||
<Zap className="size-4 text-amber-300" />
|
||||
<span>{(getZapAmount(event) || 0) / 1000}</span>
|
||||
</div>
|
||||
) : [kinds.Repost, kinds.GenericRepost].includes(event.kind) ? (
|
||||
<KindBadge kind={event.kind} variant="compact" />
|
||||
) : event.content ? (
|
||||
<RichText
|
||||
event={event}
|
||||
className="truncate line-clamp-1 text-sm"
|
||||
options={{
|
||||
showMedia: false,
|
||||
showEventEmbeds: false,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<KindBadge kind={event.kind} variant="compact" />
|
||||
)}
|
||||
{reply && (
|
||||
<ReplyPreview pointer={reply.pointer} onClick={handleReplyClick} />
|
||||
)}
|
||||
<span
|
||||
className="text-xs text-muted-foreground/70 whitespace-nowrap ml-auto"
|
||||
title={absoluteTime}
|
||||
>
|
||||
{relativeTime}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2 p-3 border-b border-border/50 last:border-0">
|
||||
<div className="flex flex-row justify-between items-center">
|
||||
|
||||
Reference in New Issue
Block a user