feat: auto-show new notes at top
This commit is contained in:
parent
53a67d8233
commit
d1b3a8c4c7
10 changed files with 32 additions and 82 deletions
|
|
@ -338,9 +338,21 @@ const NoteList = forwardRef<
|
|||
oldEvents.some((e) => e.id === event.id) ? oldEvents : [event, ...oldEvents]
|
||||
)
|
||||
} else {
|
||||
setNewEvents((oldEvents) =>
|
||||
[event, ...oldEvents].sort((a, b) => b.created_at - a.created_at)
|
||||
)
|
||||
const isAtTop = (() => {
|
||||
if (!topRef.current) return true
|
||||
const rect = topRef.current.getBoundingClientRect()
|
||||
return rect.top >= 50
|
||||
})()
|
||||
|
||||
if (isAtTop) {
|
||||
setEvents((oldEvents) =>
|
||||
oldEvents.some((e) => e.id === event.id) ? oldEvents : [event, ...oldEvents]
|
||||
)
|
||||
} else {
|
||||
setNewEvents((oldEvents) =>
|
||||
[event, ...oldEvents].sort((a, b) => b.created_at - a.created_at)
|
||||
)
|
||||
}
|
||||
}
|
||||
threadService.addRepliesToThread([event])
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue