diff --git a/src/Components/CopyToClipboard/CopyToClipboard.tsx b/src/Components/CopyToClipboard/CopyToClipboard.tsx index d0b2aef..810dcc9 100644 --- a/src/Components/CopyToClipboard/CopyToClipboard.tsx +++ b/src/Components/CopyToClipboard/CopyToClipboard.tsx @@ -2,6 +2,7 @@ import React, { useState } from 'react' import { IoIosCopy } from 'react-icons/io' import CopyToClipboardComponent from 'react-copy-to-clipboard'; import { motion } from 'framer-motion' +import { FiCopy } from 'react-icons/fi'; interface Props { text: string; @@ -40,7 +41,7 @@ export default function CopyToClipboard({ text, direction = 'bottom', iconClasse return ( <> - + setShowAlert(false), 2000) }} - className={`absolute rounded-xl text-center bg-black text-white w-full p-16 ${className} ${alertClasses}`}>Copied to clipboard + className={`absolute rounded-xl text-center bg-black text-white right-0 z-10 p-16 ${className} ${alertClasses}`}>Copied to clipboard ) diff --git a/src/Components/VoteButton/VoteButton.tsx b/src/Components/VoteButton/VoteButton.tsx index 6663884..7d49c20 100644 --- a/src/Components/VoteButton/VoteButton.tsx +++ b/src/Components/VoteButton/VoteButton.tsx @@ -62,6 +62,7 @@ export default function VoteButton({ hideVotesCoun = false, dense = false, resetCounterOnRelease = true, + onSuccess, ...props }: Props) { const [voteCnt, setVoteCnt] = useState(0) const voteCntRef = useRef(0); @@ -83,7 +84,7 @@ export default function VoteButton({ onSuccess: (amount) => { setBtnState("success"); spawnSparks(10); - props.onSuccess?.(amount); + onSuccess?.(amount); }, onError: () => setBtnState('fail'), onSetteled: () => { diff --git a/src/features/Posts/Components/Comments/Comment/Comment.tsx b/src/features/Posts/Components/Comments/Comment/Comment.tsx index 5939d09..3b44f23 100644 --- a/src/features/Posts/Components/Comments/Comment/Comment.tsx +++ b/src/features/Posts/Components/Comments/Comment/Comment.tsx @@ -1,6 +1,6 @@ import { useToggle } from "@react-hookz/web"; -import { useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { FaChevronDown, FaChevronUp } from "react-icons/fa"; import Button from "src/Components/Button/Button"; import { useAppSelector } from "src/utils/hooks"; @@ -21,7 +21,22 @@ export default function Comment({ comment, canReply, isRoot, onClickedReply, onR const [replyOpen, setReplyOpen] = useState(false); const [repliesCollapsed, toggleRepliesCollapsed] = useToggle(true) - const user = useAppSelector(s => s.user.me) + const [scrollToLatestReply, setScrollToLatestReply] = useState(true); + const repliesContainer = useRef(null!) + const user = useAppSelector(s => s.user.me); + + + useEffect(() => { + if (repliesCollapsed) + setReplyOpen(false); + }, [repliesCollapsed]) + + useEffect(() => { + if (scrollToLatestReply) { + repliesContainer.current?.querySelector(`:scope > div:nth-child(${comment.replies.length})`)?.scrollIntoView({ behavior: 'smooth', block: "center" }) + setScrollToLatestReply(false); + } + }, [comment.replies.length, scrollToLatestReply]) const clickReply = () => { if (isRoot) @@ -35,6 +50,7 @@ export default function Comment({ comment, canReply, isRoot, onClickedReply, onR await onReply?.(text); toggleRepliesCollapsed(false); setReplyOpen(false); + setScrollToLatestReply(true) return true; } catch (error) { return false; @@ -55,18 +71,23 @@ export default function Comment({ comment, canReply, isRoot, onClickedReply, onR Hide replies } } - {!repliesCollapsed && comment.replies.map(reply => )} - {replyOpen && } +
+ {!repliesCollapsed && comment.replies.map(reply => )} + {replyOpen && } +
} diff --git a/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx b/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx index 9005faa..8005b24 100644 --- a/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx +++ b/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx @@ -19,19 +19,6 @@ export default function CommentCard({ comment, canReply, onReply }: Props) { const [votesCount, setVotesCount] = useState(comment.votes_count); - // const onVote: ComponentProps['onVote'] = async (amount, config) => { - // try { - // const pr = await lightningAddressToPR(comment.author?.lightning_address ?? CONSTS.defaultLightningAddress, amount); - // const webln = await Wallet_Service.getWebln() - // const paymentResponse = await webln.sendPayment(pr); - // config.onSuccess?.() - // } catch (error) { - // config.onError?.() - // } finally { - // config.onSetteled?.(); - // } - // } - const { vote } = useVote({ itemId: comment.id, itemType: Vote_Item_Type.PostComment, diff --git a/src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx b/src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx index 8d041cc..cffbc68 100644 --- a/src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx +++ b/src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx @@ -61,17 +61,20 @@ export default function CommentsSection({ type, id }: Props) { return (
+
Discussion
{connectionStatus.status === 'Connected' &&
• Connected to {connectionStatus.connectedRelaysCount} relays 📡
} {connectionStatus.status === 'Connecting' &&
• Connecting to relays ⌛
} {connectionStatus.status === 'Not Connected' &&
• Not connected 📡
}
- {showTooltip &&
+ + {showTooltip &&
💬

Learn about how your data is stored with Nostr comments and relays

} + {!!user &&
} +
{commentsTree.map(comment => -

Nostr Settings (experimental)

+

💬 Nostr comments Experimental

Our commenting system is experimental and uses Nostr to store and relay your messages and replies to our own relay, as well as relays ran by other people in the community. We generate Nostr keys for you since there are no popular wallets which support it.

- {nostr_prv_key && <> -

- Your Nostr Private Key -

-
- -
- } -

- Your Nostr Public Key -

-
- +

Nostr keys

+ {nostr_prv_key &&
+

+ Your Nostr Private Key +

+
+ + + +
+
} +
+

+ Your Nostr Public Key +

+
+ + +
+
- type='text' - className="input-text" - value={nostr_pub_key!} - />
-

+ {/*

Connect your Nostr identity

🚧 Coming Soon 🚧

+
*/} +
+
+

+ Nostr relays +

+ toggleRelaysDropdownOpen()}> + + + + +
+ {relaysDropdownOpen && + + {CONSTS.DEFAULT_RELAYS.map((url, idx) =>
  • {url}
  • )} +
    }
    -

    - Connected Relays -

    -
      - {CONSTS.DEFAULT_RELAYS.map((url, idx) =>
    • {url}
    • )} -
    + +
    ) }