clean up & small fixes

This commit is contained in:
Ren Amamiya
2023-08-26 14:52:02 +07:00
parent 0f212828a7
commit fe28cd95bd
15 changed files with 247 additions and 264 deletions

View File

@@ -11,10 +11,13 @@ export function RepliesList({ id }: { id: string }) {
const [data, setData] = useState<null | NDKEventWithReplies[]>(null);
useEffect(() => {
let isCancelled = false;
async function fetchRepliesAndSub() {
const events = await fetchAllReplies(id);
setData(events);
if (!isCancelled) {
setData(events);
}
// subscribe for new replies
sub(
{
@@ -26,9 +29,12 @@ export function RepliesList({ id }: { id: string }) {
false
);
}
fetchRepliesAndSub();
}, []);
return () => {
isCancelled = true;
};
}, [id]);
if (!data) {
return (

View File

@@ -72,7 +72,7 @@ export function NoteStats({ id }: { id: string }) {
<span className="font-semibold text-white">
{compactNumber.format(data.reposts)}
</span>{' '}
reposts
repostrs
</p>
<span className="text-white/50">·</span>
<p className="text-white/50">