feat: 💨
This commit is contained in:
@@ -62,12 +62,7 @@ export default function ReplyNote({
|
|||||||
{show ? (
|
{show ? (
|
||||||
<>
|
<>
|
||||||
<Content className="mt-1" event={event} size="small" />
|
<Content className="mt-1" event={event} size="small" />
|
||||||
<NoteStats
|
<NoteStats className="mt-2" event={event} variant="reply" />
|
||||||
className="mt-2"
|
|
||||||
classNames={{ buttonBar: 'justify-start gap-1' }}
|
|
||||||
event={event}
|
|
||||||
variant="reply"
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ import {
|
|||||||
isReplyNoteEvent
|
isReplyNoteEvent
|
||||||
} from '@/lib/event'
|
} from '@/lib/event'
|
||||||
import { generateEventIdFromETag } from '@/lib/tag'
|
import { generateEventIdFromETag } from '@/lib/tag'
|
||||||
import { cn } from '@/lib/utils'
|
|
||||||
import { useNostr } from '@/providers/NostrProvider'
|
import { useNostr } from '@/providers/NostrProvider'
|
||||||
import { useNoteStats } from '@/providers/NoteStatsProvider'
|
import { useNoteStats } from '@/providers/NoteStatsProvider'
|
||||||
import client from '@/services/client.service'
|
import client from '@/services/client.service'
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { Event as NEvent, kinds } from 'nostr-tools'
|
import { Event as NEvent, kinds } from 'nostr-tools'
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
@@ -24,7 +22,7 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
|
|||||||
const { pubkey } = useNostr()
|
const { pubkey } = useNostr()
|
||||||
const [rootInfo, setRootInfo] = useState<{ id: string; pubkey: string } | undefined>(undefined)
|
const [rootInfo, setRootInfo] = useState<{ id: string; pubkey: string } | undefined>(undefined)
|
||||||
const [timelineKey, setTimelineKey] = useState<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 [events, setEvents] = useState<NEvent[]>([])
|
||||||
const [replies, setReplies] = useState<NEvent[]>([])
|
const [replies, setReplies] = useState<NEvent[]>([])
|
||||||
const [replyMap, setReplyMap] = useState<
|
const [replyMap, setReplyMap] = useState<
|
||||||
@@ -99,8 +97,8 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
|
|||||||
onEvents: (evts, eosed) => {
|
onEvents: (evts, eosed) => {
|
||||||
setEvents(evts.filter((evt) => isReplyNoteEvent(evt)).reverse())
|
setEvents(evts.filter((evt) => isReplyNoteEvent(evt)).reverse())
|
||||||
if (eosed) {
|
if (eosed) {
|
||||||
setLoading(false)
|
|
||||||
setUntil(evts.length >= LIMIT ? evts[evts.length - 1].created_at - 1 : undefined)
|
setUntil(evts.length >= LIMIT ? evts[evts.length - 1].created_at - 1 : undefined)
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onNew: (evt) => {
|
onNew: (evt) => {
|
||||||
@@ -202,7 +200,7 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{(loading || until) && (
|
{(loading || (!!until && replies.length > 0)) && (
|
||||||
<div
|
<div
|
||||||
className={`text-sm text-center text-muted-foreground mt-2 ${!loading ? 'hover:text-foreground cursor-pointer' : ''}`}
|
className={`text-sm text-center text-muted-foreground mt-2 ${!loading ? 'hover:text-foreground cursor-pointer' : ''}`}
|
||||||
onClick={loadMore}
|
onClick={loadMore}
|
||||||
@@ -210,11 +208,8 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
|
|||||||
{loading ? t('loading...') : t('load more older replies')}
|
{loading ? t('loading...') : t('load more older replies')}
|
||||||
</div>
|
</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" />}
|
{replies.length > 0 && (loading || until) && <Separator className="mt-2" />}
|
||||||
<div className={cn('mb-2', className)}>
|
<div className={className}>
|
||||||
{replies.map((reply) => {
|
{replies.map((reply) => {
|
||||||
const info = replyMap.get(reply.id)
|
const info = replyMap.get(reply.id)
|
||||||
return (
|
return (
|
||||||
@@ -229,6 +224,11 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</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} />
|
<div ref={bottomRef} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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': 'لم يتم العثور على الملاحظة',
|
||||||
|
'no more replies': 'لا توجد مزيد من الردود'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ export default {
|
|||||||
'Recent Supporters': 'Neueste Unterstützer',
|
'Recent Supporters': 'Neueste Unterstützer',
|
||||||
'Seen on': 'Gesehen auf',
|
'Seen on': 'Gesehen auf',
|
||||||
'Temporarily display this reply': 'Antwort vorübergehend anzeigen',
|
'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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ export default {
|
|||||||
'Recent Supporters': 'Recent Supporters',
|
'Recent Supporters': 'Recent Supporters',
|
||||||
'Seen on': 'Seen on',
|
'Seen on': 'Seen on',
|
||||||
'Temporarily display this reply': 'Temporarily display this reply',
|
'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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ export default {
|
|||||||
'Recent Supporters': 'Últimos patrocinadores',
|
'Recent Supporters': 'Últimos patrocinadores',
|
||||||
'Seen on': 'Visto en',
|
'Seen on': 'Visto en',
|
||||||
'Temporarily display this reply': 'Mostrar temporalmente esta respuesta',
|
'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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ export default {
|
|||||||
'Recent Supporters': 'Derniers soutiens',
|
'Recent Supporters': 'Derniers soutiens',
|
||||||
'Seen on': 'Vu sur',
|
'Seen on': 'Vu sur',
|
||||||
'Temporarily display this reply': 'Afficher temporairement cette réponse',
|
'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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,6 +210,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': 'ノートが見つかりません',
|
||||||
|
'no more replies': 'これ以上の返信はありません'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ export default {
|
|||||||
'Recent Supporters': 'Ostatni wspierający',
|
'Recent Supporters': 'Ostatni wspierający',
|
||||||
'Seen on': 'Widziany na',
|
'Seen on': 'Widziany na',
|
||||||
'Temporarily display this reply': 'Tymczasowo wyświetl tę odpowiedź',
|
'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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ export default {
|
|||||||
'Recent Supporters': 'Apoiadores recentes',
|
'Recent Supporters': 'Apoiadores recentes',
|
||||||
'Seen on': 'Visto em',
|
'Seen on': 'Visto em',
|
||||||
'Temporarily display this reply': 'Exibir temporariamente esta resposta',
|
'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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ export default {
|
|||||||
'Recent Supporters': 'Apoiadores Recentes',
|
'Recent Supporters': 'Apoiadores Recentes',
|
||||||
'Seen on': 'Visto em',
|
'Seen on': 'Visto em',
|
||||||
'Temporarily display this reply': 'Exibir temporariamente esta resposta',
|
'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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,6 +213,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': 'Заметка не найдена',
|
||||||
|
'no more replies': 'больше нет ответов'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,6 +210,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': '未找到该笔记',
|
||||||
|
'no more replies': '没有更多回复了'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user