mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-10-10 21:03:39 +02:00
tweak custom emojis
fix event exists service
This commit is contained in:
@@ -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());
|
const emojiTag = note.tags.filter(isEmojiTag).find((t) => t[1].toLowerCase() === match[1].toLowerCase());
|
||||||
if (emojiTag) {
|
if (emojiTag) {
|
||||||
return (
|
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;
|
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 {
|
import {
|
||||||
Box,
|
Box,
|
||||||
ButtonGroup,
|
ButtonGroup,
|
||||||
@@ -29,7 +29,7 @@ import appSettings from "../../services/settings/app-settings";
|
|||||||
import EventVerificationIcon from "../event-verification-icon";
|
import EventVerificationIcon from "../event-verification-icon";
|
||||||
import { RepostButton } from "./components/repost-button";
|
import { RepostButton } from "./components/repost-button";
|
||||||
import { QuoteRepostButton } from "./components/quote-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 NoteContentWithWarning from "./note-content-with-warning";
|
||||||
import { TrustProvider } from "../../providers/trust";
|
import { TrustProvider } from "../../providers/trust";
|
||||||
import { useRegisterIntersectionEntity } from "../../providers/intersection-observer";
|
import { useRegisterIntersectionEntity } from "../../providers/intersection-observer";
|
||||||
@@ -47,6 +47,7 @@ import { nip19 } from "nostr-tools";
|
|||||||
import NoteCommunityMetadata from "./note-community-metadata";
|
import NoteCommunityMetadata from "./note-community-metadata";
|
||||||
import useSingleEvent from "../../hooks/use-single-event";
|
import useSingleEvent from "../../hooks/use-single-event";
|
||||||
import { InlineNoteContent } from "./inline-note-content";
|
import { InlineNoteContent } from "./inline-note-content";
|
||||||
|
import NoteProxyLink from "./components/note-proxy-link";
|
||||||
|
|
||||||
export type NoteProps = Omit<CardProps, "children"> & {
|
export type NoteProps = Omit<CardProps, "children"> & {
|
||||||
event: NostrEvent;
|
event: NostrEvent;
|
||||||
@@ -79,9 +80,6 @@ export const Note = React.memo(
|
|||||||
const refs = getReferences(event);
|
const refs = getReferences(event);
|
||||||
const repliedTo = useSingleEvent(refs.replyId);
|
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 showReactionsOnNewLine = useBreakpointValue({ base: true, md: false });
|
||||||
|
|
||||||
const reactionButtons = showReactions && <NoteReactions event={event} flexWrap="wrap" variant="ghost" size="xs" />;
|
const reactionButtons = showReactions && <NoteReactions event={event} flexWrap="wrap" variant="ghost" size="xs" />;
|
||||||
@@ -138,17 +136,7 @@ export const Note = React.memo(
|
|||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
{!showReactionsOnNewLine && reactionButtons}
|
{!showReactionsOnNewLine && reactionButtons}
|
||||||
<Box flexGrow={1} />
|
<Box flexGrow={1} />
|
||||||
{externalLink && (
|
<NoteProxyLink event={event} size="xs" variant="ghost" />
|
||||||
<IconButton
|
|
||||||
as={Link}
|
|
||||||
icon={<ExternalLinkIcon />}
|
|
||||||
aria-label="Open External"
|
|
||||||
href={externalLink}
|
|
||||||
size="xs"
|
|
||||||
variant="ghost"
|
|
||||||
target="_blank"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<EventRelays event={event} />
|
<EventRelays event={event} />
|
||||||
<BookmarkButton event={event} aria-label="Bookmark note" size="xs" variant="ghost" />
|
<BookmarkButton event={event} aria-label="Bookmark note" size="xs" variant="ghost" />
|
||||||
<NoteMenu event={event} size="xs" variant="ghost" aria-label="More Options" />
|
<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];
|
const nextRelay = relayScoreboardService.getRankedRelays(Array.from(relays))[0];
|
||||||
|
|
||||||
if (!nextRelay) continue;
|
if (!nextRelay) continue;
|
||||||
|
relays.delete(nextRelay);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const sub = this.answers.get(key);
|
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 };
|
const limitFilter = Array.isArray(filter) ? filter.map((f) => ({ ...f, limit: 1 })) : { ...filter, limit: 1 };
|
||||||
request.start(limitFilter);
|
request.start(limitFilter);
|
||||||
request.onEvent.subscribe(() => {
|
request.onEvent.subscribe(() => {
|
||||||
|
this.log("Found event for", filter);
|
||||||
sub.next(true);
|
sub.next(true);
|
||||||
this.pending.delete(key);
|
this.pending.delete(key);
|
||||||
});
|
});
|
||||||
await request.onComplete;
|
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,
|
Flex,
|
||||||
IconButton,
|
IconButton,
|
||||||
Link,
|
Link,
|
||||||
|
Spacer,
|
||||||
useColorMode,
|
useColorMode,
|
||||||
useDisclosure,
|
useDisclosure,
|
||||||
} from "@chakra-ui/react";
|
} 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 BookmarkButton from "../../../components/note/components/bookmark-button";
|
||||||
import NoteCommunityMetadata from "../../../components/note/note-community-metadata";
|
import NoteCommunityMetadata from "../../../components/note/note-community-metadata";
|
||||||
import { UserDnsIdentityIcon } from "../../../components/user-dns-identity-icon";
|
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"];
|
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} />
|
<NoteZapButton event={post.event} />
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
{!showReactionsOnNewLine && reactionButtons}
|
{!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" />
|
<NoteMenu event={post.event} variant="ghost" size="sm" aria-label="More Options" />
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
@@ -109,9 +109,9 @@ const UserView = () => {
|
|||||||
]);
|
]);
|
||||||
const hasArticles = useEventExists({ kinds: [Kind.Article], authors: [pubkey] }, readRelays);
|
const hasArticles = useEventExists({ kinds: [Kind.Article], authors: [pubkey] }, readRelays);
|
||||||
const hasStreams = useEventExists({ kinds: [STREAM_KIND], authors: [pubkey] }, [
|
const hasStreams = useEventExists({ kinds: [STREAM_KIND], authors: [pubkey] }, [
|
||||||
|
"wss://relay.snort.social",
|
||||||
"wss://nos.lol",
|
"wss://nos.lol",
|
||||||
"wss://relay.damus.io",
|
"wss://relay.damus.io",
|
||||||
"wss://relay.snort.social",
|
|
||||||
"wss://nostr.wine",
|
"wss://nostr.wine",
|
||||||
...readRelays,
|
...readRelays,
|
||||||
]);
|
]);
|
||||||
@@ -124,7 +124,7 @@ const UserView = () => {
|
|||||||
if (tab.path === "streams" && hasStreams === false) return false;
|
if (tab.path === "streams" && hasStreams === false) return false;
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
[hasTracks, hasArticles, tabs],
|
[hasTracks, hasArticles, hasStreams, tabs],
|
||||||
);
|
);
|
||||||
|
|
||||||
const matches = useMatches();
|
const matches = useMatches();
|
||||||
|
Reference in New Issue
Block a user