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>
|
<script>
|
||||||
import { afterUpdate, beforeUpdate } from "svelte";
|
import { afterUpdate, beforeUpdate } from "svelte";
|
||||||
|
import { element } from "svelte/internal";
|
||||||
import { messagesStoreProvider } from "../../../stores.js";
|
import { messagesStoreProvider } from "../../../stores.js";
|
||||||
|
|
||||||
export let channelId;
|
export let channelId;
|
||||||
|
@ -20,12 +21,12 @@
|
||||||
|
|
||||||
const onScroll = (e) => {
|
const onScroll = (e) => {
|
||||||
const { scrollTop, offsetHeight, scrollHeight } = e.target;
|
const { scrollTop, offsetHeight, scrollHeight } = e.target;
|
||||||
if (scrollTop === 0) {
|
|
||||||
messages.loadOlderMessages();
|
|
||||||
}
|
|
||||||
if ((scrollTop + offsetHeight) >= scrollHeight) {
|
if ((scrollTop + offsetHeight) >= scrollHeight) {
|
||||||
messages.setIsCollectingOldMessages(true);
|
messages.setIsCollectingOldMessages(true);
|
||||||
} else {
|
} else {
|
||||||
|
if (scrollTop === 0) {
|
||||||
|
messages.loadOlderMessages();
|
||||||
|
}
|
||||||
messages.setIsCollectingOldMessages(false);
|
messages.setIsCollectingOldMessages(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue