DEV: removes setInterval as it might cause issues (#9722)

This commit is contained in:
Joffrey JAFFEUX 2020-05-10 08:57:48 +02:00 committed by GitHub
parent 862d153f54
commit 3b2b635e9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { throttle, debounce, schedule } from "@ember/runloop"; import { throttle, debounce, schedule, later } from "@ember/runloop";
import Component from "@ember/component"; import Component from "@ember/component";
import { on, observes } from "discourse-common/utils/decorators"; import { on, observes } from "discourse-common/utils/decorators";
import { findRawTemplate } from "discourse-common/lib/raw-templates"; import { findRawTemplate } from "discourse-common/lib/raw-templates";
@ -196,6 +196,8 @@ export default Component.extend({
if (!this.site.isMobileDevice) { if (!this.site.isMobileDevice) {
this._bindHover(); this._bindHover();
} }
later(this, this._onScroll, 100);
}, },
_bindModalClick() { _bindModalClick() {
@ -221,7 +223,6 @@ export default Component.extend({
_unbindEvents() { _unbindEvents() {
$(this.element).off(); $(this.element).off();
$(window).off("resize"); $(window).off("resize");
clearInterval(this._refreshInterval);
$("#reply-control").off("div-resizing"); $("#reply-control").off("div-resizing");
$("html").off("mouseup.emoji-picker"); $("html").off("mouseup.emoji-picker");
}, },
@ -370,12 +371,11 @@ export default Component.extend({
}, },
_bindSectionsScroll() { _bindSectionsScroll() {
let onScroll = () => { this.$list.on("scroll", this._onScroll.bind(this));
debounce(this, this._checkVisibleSection, 50); },
};
this.$list.on("scroll", onScroll); _onScroll() {
this._refreshInterval = setInterval(onScroll, 100); debounce(this, this._checkVisibleSection, 50);
}, },
_checkVisibleSection(force) { _checkVisibleSection(force) {
@ -420,6 +420,8 @@ export default Component.extend({
this._loadVisibleSections(); this._loadVisibleSections();
} }
later(this, this._checkVisibleSection, 100);
}, },
_loadVisibleSections() { _loadVisibleSections() {