From 3b2b635e9b3779e19c3fb03a62f64aa1dca143c1 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Sun, 10 May 2020 08:57:48 +0200 Subject: [PATCH] DEV: removes setInterval as it might cause issues (#9722) --- .../discourse/app/components/emoji-picker.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/emoji-picker.js b/app/assets/javascripts/discourse/app/components/emoji-picker.js index bafd5929a99..a77b564e593 100644 --- a/app/assets/javascripts/discourse/app/components/emoji-picker.js +++ b/app/assets/javascripts/discourse/app/components/emoji-picker.js @@ -1,5 +1,5 @@ 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 { on, observes } from "discourse-common/utils/decorators"; import { findRawTemplate } from "discourse-common/lib/raw-templates"; @@ -196,6 +196,8 @@ export default Component.extend({ if (!this.site.isMobileDevice) { this._bindHover(); } + + later(this, this._onScroll, 100); }, _bindModalClick() { @@ -221,7 +223,6 @@ export default Component.extend({ _unbindEvents() { $(this.element).off(); $(window).off("resize"); - clearInterval(this._refreshInterval); $("#reply-control").off("div-resizing"); $("html").off("mouseup.emoji-picker"); }, @@ -370,12 +371,11 @@ export default Component.extend({ }, _bindSectionsScroll() { - let onScroll = () => { - debounce(this, this._checkVisibleSection, 50); - }; + this.$list.on("scroll", this._onScroll.bind(this)); + }, - this.$list.on("scroll", onScroll); - this._refreshInterval = setInterval(onScroll, 100); + _onScroll() { + debounce(this, this._checkVisibleSection, 50); }, _checkVisibleSection(force) { @@ -420,6 +420,8 @@ export default Component.extend({ this._loadVisibleSections(); } + + later(this, this._checkVisibleSection, 100); }, _loadVisibleSections() {