Merge branch 'next'

This commit is contained in:
hzrd149 2023-07-07 16:14:37 -05:00
commit 902ffa00ba
4 changed files with 24 additions and 9 deletions
.changeset
src
helpers
views/streams/stream/stream-chat

@ -0,0 +1,5 @@
---
"nostrudel": patch
---
Fix stream view crashing when failing to parse zap request

@ -0,0 +1,5 @@
---
"nostrudel": patch
---
Fix npub in url getting replaced in post modal

@ -1,4 +1,4 @@
export const mentionNpubOrNote = /@?((npub1|note1)[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58})/gi;
export const mentionNpubOrNote = /(?:\s|^)(@|nostr:)?((npub1|note1)[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58})(?:\s|$)/gi;
export const matchImageUrls =
/https?:\/\/([\dA-z\.-]+\.[A-z\.]{2,12})((?:\/[\+~%\/\.\w\-_]*)?\.(?:svg|gif|png|jpg|jpeg|webp|avif))(\??(?:[\?#\-\+=&;%@\.\w_]*)#?(?:[\-\.\!\/\\\w]*))?/i;

@ -1,4 +1,4 @@
import React, { useRef } from "react";
import React, { useMemo, useRef } from "react";
import { Box, Flex, Text } from "@chakra-ui/react";
import { ParsedStream } from "../../../../helpers/nostr/stream";
import { UserAvatar } from "../../../../components/user-avatar";
@ -15,20 +15,25 @@ function ZapMessage({ zap, stream }: { zap: NostrEvent; stream: ParsedStream })
const ref = useRef<HTMLDivElement | null>(null);
useRegisterIntersectionEntity(ref, zap.id);
const { request, payment } = parseZapEvent(zap);
if (!payment.amount) return null;
const parsed = useMemo(() => {
try {
return parseZapEvent(zap);
} catch (e) {}
}, [zap]);
if (!parsed || !parsed.payment.amount) return null;
return (
<TrustProvider event={request}>
<TrustProvider event={parsed.request}>
<Flex direction="column" borderRadius="md" borderColor="yellow.400" borderWidth="1px" p="2" ref={ref}>
<Flex gap="2">
<LightningIcon color="yellow.400" />
<UserAvatar pubkey={request.pubkey} size="xs" />
<UserLink pubkey={request.pubkey} fontWeight="bold" color="yellow.400" />
<Text>zapped {readablizeSats(payment.amount / 1000)} sats</Text>
<UserAvatar pubkey={parsed.request.pubkey} size="xs" />
<UserLink pubkey={parsed.request.pubkey} fontWeight="bold" color="yellow.400" />
<Text>zapped {readablizeSats(parsed.payment.amount / 1000)} sats</Text>
</Flex>
<Box>
<ChatMessageContent event={request} />
<ChatMessageContent event={parsed.request} />
</Box>
</Flex>
</TrustProvider>