mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-11 05:09:36 +02:00
tweak custom emojis
fix event exists service
This commit is contained in:
parent
9a0ec6fc4b
commit
f3158d8f1f
@ -10,7 +10,14 @@ export function embedEmoji(content: EmbedableContent, note: NostrEvent | DraftNo
|
||||
const emojiTag = note.tags.filter(isEmojiTag).find((t) => t[1].toLowerCase() === match[1].toLowerCase());
|
||||
if (emojiTag) {
|
||||
return (
|
||||
<Image src={emojiTag[2]} h="1.2em" w="1.2em" display="inline-block" verticalAlign="middle" title={match[1]} />
|
||||
<Image
|
||||
src={emojiTag[2]}
|
||||
h="1.5em"
|
||||
maxW="3em"
|
||||
display="inline-block"
|
||||
verticalAlign="middle"
|
||||
title={match[1]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
23
src/components/note/components/note-proxy-link.tsx
Normal file
23
src/components/note/components/note-proxy-link.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
import { IconButton, IconButtonProps, Link } from "@chakra-ui/react";
|
||||
import { ExternalLinkIcon } from "../../icons";
|
||||
import { useMemo } from "react";
|
||||
import { NostrEvent } from "../../../types/nostr-event";
|
||||
|
||||
export default function NoteProxyLink({
|
||||
event,
|
||||
...props
|
||||
}: Omit<IconButtonProps, "aria-label"> & { event: NostrEvent }) {
|
||||
const externalLink = useMemo(() => event.tags.find((t) => t[0] === "mostr" || t[0] === "proxy"), [event])?.[1];
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
as={Link}
|
||||
icon={<ExternalLinkIcon />}
|
||||
href={externalLink}
|
||||
target="_blank"
|
||||
aria-label="Open External"
|
||||
title="Open External"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import React, { useMemo, useRef } from "react";
|
||||
import React, { useRef } from "react";
|
||||
import {
|
||||
Box,
|
||||
ButtonGroup,
|
||||
@ -29,7 +29,7 @@ import appSettings from "../../services/settings/app-settings";
|
||||
import EventVerificationIcon from "../event-verification-icon";
|
||||
import { RepostButton } from "./components/repost-button";
|
||||
import { QuoteRepostButton } from "./components/quote-repost-button";
|
||||
import { ExternalLinkIcon, ReplyIcon } from "../icons";
|
||||
import { ReplyIcon } from "../icons";
|
||||
import NoteContentWithWarning from "./note-content-with-warning";
|
||||
import { TrustProvider } from "../../providers/trust";
|
||||
import { useRegisterIntersectionEntity } from "../../providers/intersection-observer";
|
||||
@ -47,6 +47,7 @@ import { nip19 } from "nostr-tools";
|
||||
import NoteCommunityMetadata from "./note-community-metadata";
|
||||
import useSingleEvent from "../../hooks/use-single-event";
|
||||
import { InlineNoteContent } from "./inline-note-content";
|
||||
import NoteProxyLink from "./components/note-proxy-link";
|
||||
|
||||
export type NoteProps = Omit<CardProps, "children"> & {
|
||||
event: NostrEvent;
|
||||
@ -79,9 +80,6 @@ export const Note = React.memo(
|
||||
const refs = getReferences(event);
|
||||
const repliedTo = useSingleEvent(refs.replyId);
|
||||
|
||||
// find mostr external link
|
||||
const externalLink = useMemo(() => event.tags.find((t) => t[0] === "mostr" || t[0] === "proxy"), [event])?.[1];
|
||||
|
||||
const showReactionsOnNewLine = useBreakpointValue({ base: true, md: false });
|
||||
|
||||
const reactionButtons = showReactions && <NoteReactions event={event} flexWrap="wrap" variant="ghost" size="xs" />;
|
||||
@ -138,17 +136,7 @@ export const Note = React.memo(
|
||||
</ButtonGroup>
|
||||
{!showReactionsOnNewLine && reactionButtons}
|
||||
<Box flexGrow={1} />
|
||||
{externalLink && (
|
||||
<IconButton
|
||||
as={Link}
|
||||
icon={<ExternalLinkIcon />}
|
||||
aria-label="Open External"
|
||||
href={externalLink}
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
target="_blank"
|
||||
/>
|
||||
)}
|
||||
<NoteProxyLink event={event} size="xs" variant="ghost" />
|
||||
<EventRelays event={event} />
|
||||
<BookmarkButton event={event} aria-label="Bookmark note" size="xs" variant="ghost" />
|
||||
<NoteMenu event={event} size="xs" variant="ghost" aria-label="More Options" />
|
||||
|
@ -57,6 +57,7 @@ class EventExistsService {
|
||||
const nextRelay = relayScoreboardService.getRankedRelays(Array.from(relays))[0];
|
||||
|
||||
if (!nextRelay) continue;
|
||||
relays.delete(nextRelay);
|
||||
|
||||
(async () => {
|
||||
const sub = this.answers.get(key);
|
||||
@ -64,11 +65,15 @@ class EventExistsService {
|
||||
const limitFilter = Array.isArray(filter) ? filter.map((f) => ({ ...f, limit: 1 })) : { ...filter, limit: 1 };
|
||||
request.start(limitFilter);
|
||||
request.onEvent.subscribe(() => {
|
||||
this.log("Found event for", filter);
|
||||
sub.next(true);
|
||||
this.pending.delete(key);
|
||||
});
|
||||
await request.onComplete;
|
||||
if (sub.value === undefined) sub.next(false);
|
||||
if (sub.value === undefined && this.asked.get(key).size > this.pending.get(key).size) {
|
||||
this.log("Could not find event for", filter);
|
||||
sub.next(false);
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
Flex,
|
||||
IconButton,
|
||||
Link,
|
||||
Spacer,
|
||||
useColorMode,
|
||||
useDisclosure,
|
||||
} from "@chakra-ui/react";
|
||||
@ -35,6 +36,7 @@ import NoteReactions from "../../../components/note/components/note-reactions";
|
||||
import BookmarkButton from "../../../components/note/components/bookmark-button";
|
||||
import NoteCommunityMetadata from "../../../components/note/note-community-metadata";
|
||||
import { UserDnsIdentityIcon } from "../../../components/user-dns-identity-icon";
|
||||
import NoteProxyLink from "../../../components/note/components/note-proxy-link";
|
||||
|
||||
const LEVEL_COLORS = ["green", "blue", "red", "purple", "yellow", "cyan", "pink"];
|
||||
|
||||
@ -126,7 +128,9 @@ export const ThreadPost = ({ post, initShowReplies, focusId, level = -1 }: Threa
|
||||
<NoteZapButton event={post.event} />
|
||||
</ButtonGroup>
|
||||
{!showReactionsOnNewLine && reactionButtons}
|
||||
<BookmarkButton event={post.event} variant="ghost" aria-label="Bookmark" size="sm" ml="auto" />
|
||||
<Spacer />
|
||||
<NoteProxyLink event={post.event} variant="ghost" size="sm" />
|
||||
<BookmarkButton event={post.event} variant="ghost" aria-label="Bookmark" size="sm" />
|
||||
<NoteMenu event={post.event} variant="ghost" size="sm" aria-label="More Options" />
|
||||
</Flex>
|
||||
);
|
||||
|
@ -109,9 +109,9 @@ const UserView = () => {
|
||||
]);
|
||||
const hasArticles = useEventExists({ kinds: [Kind.Article], authors: [pubkey] }, readRelays);
|
||||
const hasStreams = useEventExists({ kinds: [STREAM_KIND], authors: [pubkey] }, [
|
||||
"wss://relay.snort.social",
|
||||
"wss://nos.lol",
|
||||
"wss://relay.damus.io",
|
||||
"wss://relay.snort.social",
|
||||
"wss://nostr.wine",
|
||||
...readRelays,
|
||||
]);
|
||||
@ -124,7 +124,7 @@ const UserView = () => {
|
||||
if (tab.path === "streams" && hasStreams === false) return false;
|
||||
return true;
|
||||
}),
|
||||
[hasTracks, hasArticles, tabs],
|
||||
[hasTracks, hasArticles, hasStreams, tabs],
|
||||
);
|
||||
|
||||
const matches = useMatches();
|
||||
|
Loading…
x
Reference in New Issue
Block a user