frontend: fix unnecessary requests being sent when switching between channels

This commit is contained in:
hippoz 2022-04-21 02:11:44 +03:00
parent 459b1c6703
commit e19a3aa6cc
Signed by: hippoz
GPG key ID: 7C52899193467641

View file

@ -1,5 +1,6 @@
<script>
import { afterUpdate, beforeUpdate } from "svelte";
import { element } from "svelte/internal";
import { messagesStoreProvider } from "../../../stores.js";
export let channelId;
@ -20,12 +21,12 @@
const onScroll = (e) => {
const { scrollTop, offsetHeight, scrollHeight } = e.target;
if (scrollTop === 0) {
messages.loadOlderMessages();
}
if ((scrollTop + offsetHeight) >= scrollHeight) {
messages.setIsCollectingOldMessages(true);
} else {
if (scrollTop === 0) {
messages.loadOlderMessages();
}
messages.setIsCollectingOldMessages(false);
}
};