mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-29 11:12:12 +01:00
show pow on notes
This commit is contained in:
parent
53b04b3a4a
commit
76f4cb0bdb
@ -51,6 +51,7 @@ import EventInteractionDetailsModal from "../event-interactions-modal";
|
||||
import singleEventService from "../../services/single-event";
|
||||
import { AddressPointer, EventPointer } from "nostr-tools/lib/types/nip19";
|
||||
import { nip19 } from "nostr-tools";
|
||||
import POWIcon from "../pow-icon";
|
||||
|
||||
function ReplyToE({ pointer }: { pointer: EventPointer }) {
|
||||
const event = useSingleEvent(pointer.id, pointer.relays);
|
||||
@ -156,6 +157,7 @@ export const Note = React.memo(
|
||||
<UserAvatarLink pubkey={event.pubkey} size={["xs", "sm"]} />
|
||||
<UserLink pubkey={event.pubkey} isTruncated fontWeight="bold" fontSize="lg" />
|
||||
<UserDnsIdentityIcon pubkey={event.pubkey} onlyIcon />
|
||||
<POWIcon event={event} boxSize={5} />
|
||||
<Flex grow={1} />
|
||||
{showSignatureVerification && <EventVerificationIcon event={event} />}
|
||||
{!hideDrawerButton && (
|
||||
|
28
src/components/pow-icon.tsx
Normal file
28
src/components/pow-icon.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
import { IconProps, Tooltip } from "@chakra-ui/react";
|
||||
import { NostrEvent } from "../types/nostr-event";
|
||||
import { nip13 } from "nostr-tools";
|
||||
import Dice1 from "./icons/dice-1";
|
||||
import Dice2 from "./icons/dice-2";
|
||||
import Dice3 from "./icons/dice-3";
|
||||
import Dice4 from "./icons/dice-4";
|
||||
import Dice5 from "./icons/dice-5";
|
||||
import Dice6 from "./icons/dice-6";
|
||||
|
||||
export default function POWIcon({ event, ...props }: IconProps & { event: NostrEvent }) {
|
||||
const pow = nip13.getPow(event.id);
|
||||
if (pow < 8) return null;
|
||||
|
||||
let Icon = Dice1;
|
||||
if (pow >= 16) Icon = Dice2;
|
||||
if (pow >= 24) Icon = Dice3;
|
||||
if (pow >= 32) Icon = Dice3;
|
||||
if (pow >= 48) Icon = Dice4;
|
||||
if (pow >= 64) Icon = Dice5;
|
||||
if (pow >= 86) Icon = Dice6;
|
||||
|
||||
return (
|
||||
<Tooltip label={String(pow)}>
|
||||
<Icon {...props} />
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
@ -40,6 +40,7 @@ import { getSharableEventAddress } from "../../../helpers/nip19";
|
||||
import { useRegisterIntersectionEntity } from "../../../providers/local/intersection-observer";
|
||||
import useAppSettings from "../../../hooks/use-app-settings";
|
||||
import useThreadColorLevelProps from "../../../hooks/use-thread-color-level-props";
|
||||
import POWIcon from "../../../components/pow-icon";
|
||||
|
||||
export type ThreadItemProps = {
|
||||
post: ThreadItem;
|
||||
@ -78,6 +79,7 @@ export const ThreadPost = memo(({ post, initShowReplies, focusId, level = -1 }:
|
||||
<UserAvatarLink pubkey={post.event.pubkey} size="sm" />
|
||||
<UserLink pubkey={post.event.pubkey} fontWeight="bold" isTruncated />
|
||||
<UserDnsIdentityIcon pubkey={post.event.pubkey} onlyIcon />
|
||||
<POWIcon event={post.event} boxSize={5} />
|
||||
<Link as={RouterLink} whiteSpace="nowrap" color="current" to={`/n/${getSharableEventAddress(post.event)}`}>
|
||||
<Timestamp timestamp={post.event.created_at} />
|
||||
</Link>
|
||||
|
Loading…
x
Reference in New Issue
Block a user