Skip to content

Commit af634f8

Browse files
committed
feat: adjust the order of the conversation list
1 parent 01ec65a commit af634f8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/App.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,14 @@ function Main() {
181181
document.getElementById('message-input')?.focus() // better way?
182182
}, [messageInput])
183183

184+
const sessionListRef = useRef<HTMLDivElement>(null)
185+
const handleCreateNewSession = () => {
186+
store.createEmptyChatSession()
187+
if (sessionListRef.current) {
188+
sessionListRef.current.scrollTo(0, 0)
189+
}
190+
}
191+
184192
return (
185193
<Box sx={{ height: '100vh' }}>
186194
<Grid container spacing={2} sx={{
@@ -230,9 +238,12 @@ function Main() {
230238
{t('chat')}
231239
</ListSubheader>
232240
}
241+
component="div"
242+
ref={sessionListRef}
243+
// dense
233244
>
234245
{
235-
store.chatSessions.map((session, ix) => (
246+
[...store.chatSessions].reverse().map((session, ix) => (
236247
<SessionItem key={session.id}
237248
selected={store.currentSession.id === session.id}
238249
session={session}
@@ -254,7 +265,7 @@ function Main() {
254265

255266
<Divider />
256267

257-
<MenuItem onClick={() => store.createEmptyChatSession()} >
268+
<MenuItem onClick={handleCreateNewSession} >
258269
<ListItemIcon>
259270
<IconButton><AddIcon fontSize="small" /></IconButton>
260271
</ListItemIcon>

src/Block.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ function _Block(props: Props) {
197197
/>
198198
) : (
199199
<Box
200-
sx={{
201-
// bgcolor: "Background",
202-
}}
203200
dangerouslySetInnerHTML={{ __html: md.render(msg.content) }}
204201
/>
205202
)

0 commit comments

Comments
 (0)