|
|
|
@ -10,6 +10,7 @@ import dayjs from 'dayjs' |
|
|
|
import { Event, Filter, kinds } from 'nostr-tools' |
|
|
|
import { Event, Filter, kinds } from 'nostr-tools' |
|
|
|
import { useEffect, useMemo, useRef, useState } from 'react' |
|
|
|
import { useEffect, useMemo, useRef, useState } from 'react' |
|
|
|
import { useTranslation } from 'react-i18next' |
|
|
|
import { useTranslation } from 'react-i18next' |
|
|
|
|
|
|
|
import PullToRefresh from 'react-simple-pull-to-refresh' |
|
|
|
import NoteCard from '../NoteCard' |
|
|
|
import NoteCard from '../NoteCard' |
|
|
|
|
|
|
|
|
|
|
|
const NORMAL_RELAY_LIMIT = 100 |
|
|
|
const NORMAL_RELAY_LIMIT = 100 |
|
|
|
@ -150,20 +151,32 @@ export default function NoteList({ |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className={cn('space-y-2 sm:space-y-4', className)}> |
|
|
|
<div className={cn('space-y-2 sm:space-y-4', className)}> |
|
|
|
<DisplayRepliesSwitch displayReplies={displayReplies} setDisplayReplies={setDisplayReplies} /> |
|
|
|
<DisplayRepliesSwitch displayReplies={displayReplies} setDisplayReplies={setDisplayReplies} /> |
|
|
|
{newEvents.length > 0 && ( |
|
|
|
<PullToRefresh |
|
|
|
<div className="flex justify-center w-full max-sm:mt-2"> |
|
|
|
onRefresh={async () => |
|
|
|
<Button size="lg" onClick={showNewEvents}> |
|
|
|
new Promise((resolve) => { |
|
|
|
{t('show new notes')} |
|
|
|
setRefreshCount((pre) => pre + 1) |
|
|
|
</Button> |
|
|
|
setTimeout(resolve, 1000) |
|
|
|
</div> |
|
|
|
}) |
|
|
|
)} |
|
|
|
} |
|
|
|
<div className="flex flex-col sm:gap-4"> |
|
|
|
pullingContent="" |
|
|
|
{events |
|
|
|
> |
|
|
|
.filter((event) => displayReplies || !isReplyNoteEvent(event)) |
|
|
|
<> |
|
|
|
.map((event) => ( |
|
|
|
{newEvents.filter((event) => displayReplies || !isReplyNoteEvent(event)).length > 0 && ( |
|
|
|
<NoteCard key={event.id} className="w-full" event={event} /> |
|
|
|
<div className="flex justify-center w-full max-sm:mt-2"> |
|
|
|
))} |
|
|
|
<Button size="lg" onClick={showNewEvents}> |
|
|
|
</div> |
|
|
|
{t('show new notes')} |
|
|
|
|
|
|
|
</Button> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
<div className="flex flex-col sm:gap-4"> |
|
|
|
|
|
|
|
{events |
|
|
|
|
|
|
|
.filter((event) => displayReplies || !isReplyNoteEvent(event)) |
|
|
|
|
|
|
|
.map((event) => ( |
|
|
|
|
|
|
|
<NoteCard key={event.id} className="w-full" event={event} /> |
|
|
|
|
|
|
|
))} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
</PullToRefresh> |
|
|
|
<div className="text-center text-sm text-muted-foreground"> |
|
|
|
<div className="text-center text-sm text-muted-foreground"> |
|
|
|
{hasMore ? ( |
|
|
|
{hasMore ? ( |
|
|
|
<div ref={bottomRef}>{t('loading...')}</div> |
|
|
|
<div ref={bottomRef}>{t('loading...')}</div> |
|
|
|
|