Compare commits

...

1 Commits

Author SHA1 Message Date
Innei c505674088 🐛 fix: preserve scroll position when switching sessions
When switching between topics/sessions, the displayMessages were cleared
to empty before replaceMessages was called, causing the virtual list to
reset its scroll position to the bottom.

Now replaceMessages is called directly without clearing first, preserving
the scroll position. Empty state is only set when no messages are available.

Closes #4984
2026-04-22 18:26:47 +08:00
+2 -2
View File
@@ -85,8 +85,6 @@ const StoreUpdater = memo<StoreUpdaterProps>(
// when calling onMessagesChange (otherwise writes to the old topic key)
storeApi.setState({
context,
dbMessages: messages ?? [],
displayMessages: [],
messagesInit: false,
});
@@ -94,6 +92,8 @@ const StoreUpdater = memo<StoreUpdaterProps>(
if (messages) {
storeApi.getState().replaceMessages(messages);
storeApi.setState({ messagesInit: true });
} else {
storeApi.setState({ dbMessages: [], displayMessages: [] });
}
}
}, [contextKey]); // eslint-disable-line react-hooks/exhaustive-deps