Scroll to last position when re-opening a chat.

This commit is contained in:
Paul
2021-08-07 20:53:17 +01:00
parent 0d415b4d5b
commit 2a497c5d51
2 changed files with 7 additions and 4 deletions

View File

@@ -173,7 +173,7 @@ export const MessageArea = observer(({ channel }: Props) => {
if (message) return;
if (renderer.state === "RENDER") {
runInAction(() => (renderer.fetching = true));
setScrollState({ type: "ScrollTop", y: 151 });
setScrollState({ type: "ScrollTop", y: renderer.scrollPosition });
} else {
renderer.init();
}
@@ -245,12 +245,14 @@ export const MessageArea = observer(({ channel }: Props) => {
if (!current) return;
async function onScroll() {
renderer.scrollPosition = current!.scrollTop;
if (atTop(100)) {
renderer.loadTop(ref.current!);
renderer.loadTop(current!);
}
if (atBottom(100)) {
renderer.loadBottom(ref.current!);
renderer.loadBottom(current!);
}
}