From 00e605214aed23b825792663aafc891a9002444b Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Thu, 21 Dec 2023 22:49:13 -0600 Subject: [PATCH] hide zaps from muted users in stream --- src/components/post-modal/index.tsx | 7 +++++-- src/views/streams/stream/stream-chat/zap-message.tsx | 3 +++ src/views/thread/components/reply-form.tsx | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/post-modal/index.tsx b/src/components/post-modal/index.tsx index e5619a0c2..61ed3a010 100644 --- a/src/components/post-modal/index.tsx +++ b/src/components/post-modal/index.tsx @@ -47,6 +47,7 @@ import useCurrentAccount from "../../hooks/use-current-account"; import useCacheForm from "../../hooks/use-cache-form"; import { useAdditionalRelayContext } from "../../providers/additional-relay-context"; import { useTextAreaUploadFileWithForm } from "../../hooks/use-textarea-upload-file"; +import { useThrottle } from "react-use"; type FormValues = { subject: string; @@ -147,6 +148,8 @@ export default function PostModal({ const canSubmit = getValues().content.length > 0; const mentions = getContentMentions(correctContentMentions(getValues().content)); + const previewDraft = useThrottle(getDraft(), 500); + const renderContent = () => { if (publishAction) { return ( @@ -176,12 +179,12 @@ export default function PostModal({ if (e.ctrlKey && e.key === "Enter") submit(); }} /> - {getValues().content.length > 0 && ( + {previewDraft.content.length > 0 && ( Preview: - + diff --git a/src/views/streams/stream/stream-chat/zap-message.tsx b/src/views/streams/stream/stream-chat/zap-message.tsx index 53996f363..7855f392e 100644 --- a/src/views/streams/stream/stream-chat/zap-message.tsx +++ b/src/views/streams/stream/stream-chat/zap-message.tsx @@ -11,6 +11,7 @@ import { parseZapEvent } from "../../../../helpers/nostr/zaps"; import { readablizeSats } from "../../../../helpers/bolt11"; import { TrustProvider } from "../../../../providers/trust"; import ChatMessageContent from "./chat-message-content"; +import useClientSideMuteFilter from "../../../../hooks/use-client-side-mute-filter"; function ZapMessage({ zap, stream }: { zap: NostrEvent; stream: ParsedStream }) { const ref = useRef(null); @@ -21,8 +22,10 @@ function ZapMessage({ zap, stream }: { zap: NostrEvent; stream: ParsedStream }) return parseZapEvent(zap); } catch (e) {} }, [zap]); + const clientMuteFilter = useClientSideMuteFilter(); if (!parsed || !parsed.payment.amount) return null; + if (clientMuteFilter(parsed.event)) return null; return ( diff --git a/src/views/thread/components/reply-form.tsx b/src/views/thread/components/reply-form.tsx index da77ff2e3..8ad59bed2 100644 --- a/src/views/thread/components/reply-form.tsx +++ b/src/views/thread/components/reply-form.tsx @@ -25,6 +25,7 @@ import { useContextEmojis } from "../../../providers/emoji-provider"; import { TrustProvider } from "../../../providers/trust"; import { nostrBuildUploadImage } from "../../../helpers/nostr-build"; import { UploadImageIcon } from "../../../components/icons"; +import { useThrottle } from "react-use"; export type ReplyFormProps = { item: ThreadItem; @@ -96,6 +97,7 @@ export default function ReplyForm({ item, onCancel, onSubmitted, replyKind = Kin }); const formRef = useRef(null); + const previewDraft = useThrottle(draft, 500); return ( @@ -142,10 +144,10 @@ export default function ReplyForm({ item, onCancel, onSubmitted, replyKind = Kin - {getValues().content.length > 0 && ( + {previewDraft.content.length > 0 && ( - + )}