feat: 💨

This commit is contained in:
codytseng
2025-03-12 21:49:52 +08:00
parent b13742b165
commit 9026fac581
13 changed files with 32 additions and 26 deletions

View File

@@ -62,12 +62,7 @@ export default function ReplyNote({
{show ? (
<>
<Content className="mt-1" event={event} size="small" />
<NoteStats
className="mt-2"
classNames={{ buttonBar: 'justify-start gap-1' }}
event={event}
variant="reply"
/>
<NoteStats className="mt-2" event={event} variant="reply" />
</>
) : (
<Button

View File

@@ -7,11 +7,9 @@ import {
isReplyNoteEvent
} from '@/lib/event'
import { generateEventIdFromETag } from '@/lib/tag'
import { cn } from '@/lib/utils'
import { useNostr } from '@/providers/NostrProvider'
import { useNoteStats } from '@/providers/NoteStatsProvider'
import client from '@/services/client.service'
import dayjs from 'dayjs'
import { Event as NEvent, kinds } from 'nostr-tools'
import { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -24,7 +22,7 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
const { pubkey } = useNostr()
const [rootInfo, setRootInfo] = useState<{ id: string; pubkey: string } | undefined>(undefined)
const [timelineKey, setTimelineKey] = useState<string | undefined>(undefined)
const [until, setUntil] = useState<number | undefined>(() => dayjs().unix())
const [until, setUntil] = useState<number | undefined>(undefined)
const [events, setEvents] = useState<NEvent[]>([])
const [replies, setReplies] = useState<NEvent[]>([])
const [replyMap, setReplyMap] = useState<
@@ -99,8 +97,8 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
onEvents: (evts, eosed) => {
setEvents(evts.filter((evt) => isReplyNoteEvent(evt)).reverse())
if (eosed) {
setLoading(false)
setUntil(evts.length >= LIMIT ? evts[evts.length - 1].created_at - 1 : undefined)
setLoading(false)
}
},
onNew: (evt) => {
@@ -202,7 +200,7 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
return (
<>
{(loading || until) && (
{(loading || (!!until && replies.length > 0)) && (
<div
className={`text-sm text-center text-muted-foreground mt-2 ${!loading ? 'hover:text-foreground cursor-pointer' : ''}`}
onClick={loadMore}
@@ -210,11 +208,8 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
{loading ? t('loading...') : t('load more older replies')}
</div>
)}
{replies.length === 0 && !loading && !until && (
<div className="text-sm mt-2 text-center text-muted-foreground">{t('no replies')}</div>
)}
{replies.length > 0 && (loading || until) && <Separator className="mt-2" />}
<div className={cn('mb-2', className)}>
<div className={className}>
{replies.map((reply) => {
const info = replyMap.get(reply.id)
return (
@@ -229,6 +224,11 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
)
})}
</div>
{!loading && (
<div className="text-sm mt-2 text-center text-muted-foreground">
{replies.length > 0 ? t('no more replies') : t('no replies')}
</div>
)}
<div ref={bottomRef} />
</>
)

View File

@@ -209,6 +209,7 @@ export default {
'Recent Supporters': 'الداعمين الجدد',
'Seen on': 'شوهد على',
'Temporarily display this reply': 'عرض هذا الرد مؤقتاً',
'Not found the note': 'لم يتم العثور على الملاحظة'
'Not found the note': 'لم يتم العثور على الملاحظة',
'no more replies': 'لا توجد مزيد من الردود'
}
}

View File

@@ -213,6 +213,7 @@ export default {
'Recent Supporters': 'Neueste Unterstützer',
'Seen on': 'Gesehen auf',
'Temporarily display this reply': 'Antwort vorübergehend anzeigen',
'Not found the note': 'Die Notiz wurde nicht gefunden'
'Not found the note': 'Die Notiz wurde nicht gefunden',
'no more replies': 'keine weiteren Antworten'
}
}

View File

@@ -209,6 +209,7 @@ export default {
'Recent Supporters': 'Recent Supporters',
'Seen on': 'Seen on',
'Temporarily display this reply': 'Temporarily display this reply',
'Not found the note': 'Not found the note'
'Not found the note': 'Not found the note',
'no more replies': 'no more replies'
}
}

View File

@@ -213,6 +213,7 @@ export default {
'Recent Supporters': 'Últimos patrocinadores',
'Seen on': 'Visto en',
'Temporarily display this reply': 'Mostrar temporalmente esta respuesta',
'Not found the note': 'No se encontró la nota'
'Not found the note': 'No se encontró la nota',
'no more replies': 'no hay más respuestas'
}
}

View File

@@ -212,6 +212,7 @@ export default {
'Recent Supporters': 'Derniers soutiens',
'Seen on': 'Vu sur',
'Temporarily display this reply': 'Afficher temporairement cette réponse',
'Not found the note': 'Note introuvable'
'Not found the note': 'Note introuvable',
'no more replies': 'aucune autre réponse'
}
}

View File

@@ -210,6 +210,7 @@ export default {
'Recent Supporters': '最近のサポーター',
'Seen on': '見た',
'Temporarily display this reply': 'この返信を一時的に表示',
'Not found the note': 'ノートが見つかりません'
'Not found the note': 'ノートが見つかりません',
'no more replies': 'これ以上の返信はありません'
}
}

View File

@@ -211,6 +211,7 @@ export default {
'Recent Supporters': 'Ostatni wspierający',
'Seen on': 'Widziany na',
'Temporarily display this reply': 'Tymczasowo wyświetl tę odpowiedź',
'Not found the note': 'Nie znaleziono wpisu'
'Not found the note': 'Nie znaleziono wpisu',
'no more replies': 'brak kolejnych odpowiedzi'
}
}

View File

@@ -211,6 +211,7 @@ export default {
'Recent Supporters': 'Apoiadores recentes',
'Seen on': 'Visto em',
'Temporarily display this reply': 'Exibir temporariamente esta resposta',
'Not found the note': 'Nota não encontrada'
'Not found the note': 'Nota não encontrada',
'no more replies': 'não há mais respostas'
}
}

View File

@@ -212,6 +212,7 @@ export default {
'Recent Supporters': 'Apoiadores Recentes',
'Seen on': 'Visto em',
'Temporarily display this reply': 'Exibir temporariamente esta resposta',
'Not found the note': 'Nota não encontrada'
'Not found the note': 'Nota não encontrada',
'no more replies': 'não há mais respostas'
}
}

View File

@@ -213,6 +213,7 @@ export default {
'Recent Supporters': 'Недавние спонсоры',
'Seen on': 'Просмотрено на',
'Temporarily display this reply': 'Временно отобразить этот ответ',
'Not found the note': 'Заметка не найдена'
'Not found the note': 'Заметка не найдена',
'no more replies': 'больше нет ответов'
}
}

View File

@@ -210,6 +210,7 @@ export default {
'Recent Supporters': '最近的支持者',
'Seen on': '来自',
'Temporarily display this reply': '临时显示此回复',
'Not found the note': '未找到该笔记'
'Not found the note': '未找到该笔记',
'no more replies': '没有更多回复了'
}
}