feat: immediately insert user-created event into feed (#534)

This commit is contained in:
2025-09-04 03:42:13 +01:00
committed by GitHub
parent 336c6e993a
commit 24f0b32611

View File

@@ -52,7 +52,7 @@ const NoteList = forwardRef(
ref
) => {
const { t } = useTranslation()
const { startLogin } = useNostr()
const { startLogin, pubkey } = useNostr()
const { isUserTrusted } = useUserTrust()
const { mutePubkeySet } = useMuteList()
const { hideContentMentioningMutedUsers } = useContentPolicy()
@@ -164,9 +164,15 @@ const NoteList = forwardRef(
}
},
onNew: (event) => {
setNewEvents((oldEvents) =>
[event, ...oldEvents].sort((a, b) => b.created_at - a.created_at)
)
if (pubkey && event.pubkey === pubkey) {
// If the new event is from the current user, insert it directly into the feed
setEvents((oldEvents) => (oldEvents.some((e) => e.id === event.id) ? oldEvents : [event, ...oldEvents]))
} else {
// Otherwise, buffer it and show the New Notes button
setNewEvents((oldEvents) =>
[event, ...oldEvents].sort((a, b) => b.created_at - a.created_at)
)
}
}
},
{