frontend: fix unnecessary requests being sent when switching between channels
This commit is contained in:
parent
459b1c6703
commit
e19a3aa6cc
1 changed files with 4 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue