fix replies

This commit is contained in:
smolgrrr 2024-08-25 19:17:34 +10:00
parent 7f991002ee
commit 8b6e605fd9
2 changed files with 17 additions and 7 deletions

View File

@ -6,7 +6,6 @@ import { UnsignedEvent, Event as NostrEvent, nip19 } from "nostr-tools";
import { useSubmitForm } from "./handleSubmit"; import { useSubmitForm } from "./handleSubmit";
import "../../styles/Form.css"; import "../../styles/Form.css";
import EmotePicker from "../modals/EmotePicker/EmotePicker"; import EmotePicker from "../modals/EmotePicker/EmotePicker";
import emotes from "../modals/EmotePicker/custom_emojis.json"
import { DEFAULT_DIFFICULTY } from "../../config"; import { DEFAULT_DIFFICULTY } from "../../config";
interface FormProps { interface FormProps {
@ -43,11 +42,11 @@ const NewNoteCard = ({
} }
if (refEvent && tagType) { if (refEvent && tagType) {
unsigned.tags = Array.from(new Set(unsigned.tags.concat(refEvent.tags))); unsigned.tags = Array.from(new Set(unsigned.tags.concat(refEvent.tags.filter(tag => tag[0] === 'e' || tag[0] === 'p'))));
unsigned.tags.push(['p', refEvent.pubkey]); unsigned.tags.push(['p', refEvent.pubkey]);
if (tagType === 'Reply') { if (tagType === 'Reply') {
unsigned.tags.push(['e', refEvent.id, refEvent.tags.some(tag => tag[0] === 'e') ? 'root' : '']); unsigned.tags.push(['e', refEvent.id]);
} else { } else {
if (tagType === 'Quote') { if (tagType === 'Quote') {
setComment(comment + '\nnostr:' + nip19.noteEncode(refEvent.id)); setComment(comment + '\nnostr:' + nip19.noteEncode(refEvent.id));
@ -168,10 +167,9 @@ const NewNoteCard = ({
</div> </div>
{doingWorkProp ? ( {doingWorkProp ? (
<div className="flex animate-pulse text-xs text-gray-300"> <div className="flex animate-pulse text-xs text-gray-300">
<CpuChipIcon className="h-4 w-4 ml-auto" /> <span className="ml-auto">Doing Work:</span>
<span>Doing Work:</span>
{hashrate && <span>{hashrate > 100000 ? `${(hashrate / 1000).toFixed(0)}k` : hashrate}</span>}H/s {hashrate && <span>{hashrate > 100000 ? `${(hashrate / 1000).toFixed(0)}k` : hashrate}</span>}H/s
<span className="pl-1"> (PB:{bestPow})</span> <span className="pl-1"> (PB:{bestPow}</span><CpuChipIcon className="h-4 w-4" />)
</div> </div>
) : null} ) : null}
</div> </div>

View File

@ -4,10 +4,22 @@ import NewNoteCard from "../forms/PostFormCard";
import { DEFAULT_DIFFICULTY } from "../../config"; import { DEFAULT_DIFFICULTY } from "../../config";
import PostCard from "../modals/PostCard"; import PostCard from "../modals/PostCard";
import { useFetchEvents } from "../../hooks/useFetchEvents"; import { useFetchEvents } from "../../hooks/useFetchEvents";
import { useState, useEffect } from "react";
const Home = () => { const Home = () => {
const filterDifficulty = localStorage.getItem("filterDifficulty") || DEFAULT_DIFFICULTY; const filterDifficulty = localStorage.getItem("filterDifficulty") || DEFAULT_DIFFICULTY;
const { noteEvents, metadataEvents } = useFetchEvents(); const { noteEvents, metadataEvents } = useFetchEvents();
const [isAnimating, setIsAnimating] = useState(true);
// Step 3: Use useEffect to remove the animation class after 3 seconds
useEffect(() => {
const timer = setTimeout(() => {
setIsAnimating(false);
}, 3000); // 3000 milliseconds = 3 seconds
return () => clearTimeout(timer); // Cleanup the timer
}, []); // Empty dependency array means this effect runs once on mount
const postEvents: Event[] = noteEvents const postEvents: Event[] = noteEvents
.filter((event) => .filter((event) =>
@ -43,7 +55,7 @@ const Home = () => {
<div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2"> <div className="w-full px-4 sm:px-0 sm:max-w-xl mx-auto my-2">
<NewNoteCard /> <NewNoteCard />
</div> </div>
<div className="grid grid-cols-1 max-w-xl mx-auto gap-1 px-4"> <div className={`grid grid-cols-1 max-w-xl mx-auto gap-1 px-4 ${isAnimating ? 'animate-pulse' : ''}`}>
{sortedEvents.map((event) => ( {sortedEvents.map((event) => (
<PostCard <PostCard
key={event.postEvent.id} key={event.postEvent.id}