DEV: attempts to fix various leaks (#9428)

DEV: attempts to fix various leaks (#9428)

  • DEV: attempts to fix various leaks

  • scheduleOnce doesnt work with anon function

  • removes the I18n change

diff --git a/app/assets/javascripts/discourse/components/composer-body.js b/app/assets/javascripts/discourse/components/composer-body.js
index 80bb8d3..e5a6e82 100644
--- a/app/assets/javascripts/discourse/components/composer-body.js
+++ b/app/assets/javascripts/discourse/components/composer-body.js
@@ -1,7 +1,7 @@
 import {
   run,
   cancel,
-  scheduleOnce,
+  schedule,
   later,
   debounce,
   throttle
@@ -65,7 +65,7 @@ export default Component.extend(KeyEnterEscape, {
     "composer.canEditTopicFeaturedLink"
   )
   resize() {
-    scheduleOnce("afterRender", () => {
+    schedule("afterRender", () => {
       if (!this.element || this.isDestroying || this.isDestroyed) {
         return;
       }
diff --git a/app/assets/javascripts/discourse/components/composer-editor.js b/app/assets/javascripts/discourse/components/composer-editor.js
index b14b0af..e6e000a 100644
--- a/app/assets/javascripts/discourse/components/composer-editor.js
+++ b/app/assets/javascripts/discourse/components/composer-editor.js
@@ -1,4 +1,4 @@
-import { debounce, later, next, scheduleOnce, throttle } from "@ember/runloop";
+import { debounce, later, next, schedule, throttle } from "@ember/runloop";
 import Component from "@ember/component";
 import userSearch from "discourse/lib/user-search";
 import discourseComputed, {
@@ -194,7 +194,7 @@ export default Component.extend({
         transformComplete: v => v.username || v.name,
         afterComplete() {
           // ensures textarea scroll position is correct
-          scheduleOnce("afterRender", () => $input.blur().focus());
+          schedule("afterRender", () => $input.blur().focus());
         },
         triggerRule: textarea =>
           !inCodeBlock(textarea.value, caretPosition(textarea))
@@ -323,7 +323,7 @@ export default Component.extend({
       this.appEvents.on(event, this, this._resetShouldBuildScrollMap);
     });
 
-    scheduleOnce("afterRender", () => {
+    schedule("afterRender", () => {
       $input.on("touchstart mouseenter", () => {
         if (!$preview.is(":visible")) return;
         $preview.off("scroll");
@@ -569,7 +569,7 @@ export default Component.extend({
   },
 
   _warnMentionedGroups($preview) {
-    scheduleOnce("afterRender", () => {
+    schedule("afterRender", () => {
       var found = this.warnedGroupMentions || [];
       $preview.find(".mention-group.notify").each((idx, e) => {
         const $e = $(e);
@@ -597,7 +597,7 @@ export default Component.extend({
       return;
     }
 
-    scheduleOnce("afterRender", () => {
+    schedule("afterRender", () => {
       let found = this.warnedCannotSeeMentions || [];
 
       $preview.find(".mention.cannot-see").each((idx, e) => {
diff --git a/app/assets/javascripts/discourse/components/d-editor.js b/app/assets/javascripts/discourse/components/d-editor.js
index 4dd2c72..11ec7b0 100644
--- a/app/assets/javascripts/discourse/components/d-editor.js
+++ b/app/assets/javascripts/discourse/components/d-editor.js
@@ -356,7 +356,7 @@ export default Component.extend({
         return;
       }
       this.set("preview", cooked);
-      scheduleOnce("afterRender", () => {
+      schedule("afterRender", () => {
         if (this._state !== "inDOM") {
           return;
         }
@@ -559,7 +559,7 @@ export default Component.extend({
   },
 
   _selectText(from, length) {
-    scheduleOnce("afterRender", () => {
+    schedule("afterRender", () => {
       const textarea = this.element.querySelector("textarea.d-editor-input");
       const $textarea = $(textarea);
       const oldScrollPos = $textarea.scrollTop();
@@ -898,7 +898,7 @@ export default Component.extend({
   // ensures textarea scroll position is correct
   _focusTextArea() {
     const textarea = this.element.querySelector("textarea.d-editor-input");
-    scheduleOnce("afterRender", () => {
+    schedule("afterRender", () => {
       textarea.blur();
       textarea.focus();
     });
diff --git a/app/assets/javascripts/discourse/components/edit-category-topic-template.js b/app/assets/javascripts/discourse/components/edit-category-topic-template.js
index 9a5d7d7..1ccf804 100644
--- a/app/assets/javascripts/discourse/components/edit-category-topic-template.js
+++ b/app/assets/javascripts/discourse/components/edit-category-topic-template.js
@@ -1,4 +1,4 @@
-import { scheduleOnce } from "@ember/runloop";
+import { schedule } from "@ember/runloop";
 import { buildCategoryPanel } from "discourse/components/edit-category-panel";
 import { observes } from "discourse-common/utils/decorators";
 
@@ -6,7 +6,7 @@ export default buildCategoryPanel("topic-template", {
   @observes("activeTab")
   _activeTabChanged: function() {
     if (this.activeTab) {
-      scheduleOnce("afterRender", () =>
+      schedule("afterRender", () =>
         this.element.querySelector(".d-editor-input").focus()
       );
     }
diff --git a/app/assets/javascripts/discourse/components/emoji-picker.js b/app/assets/javascripts/discourse/components/emoji-picker.js
index 88b7599..90e2fef 100644
--- a/app/assets/javascripts/discourse/components/emoji-picker.js
+++ b/app/assets/javascripts/discourse/components/emoji-picker.js
@@ -1,5 +1,5 @@
 import { inject as service } from "@ember/service";
-import { schedule } from "@ember/runloop";
+import { throttle, debounce, schedule } from "@ember/runloop";
 import Component from "@ember/component";
 import { on, observes } from "discourse-common/utils/decorators";
 import { findRawTemplate } from "discourse/lib/raw-templates";
@@ -12,8 +12,6 @@ import {
 import { safariHacksDisabled } from "discourse/lib/utilities";
 import ENV, { INPUT_DELAY } from "discourse-common/config/environment";
 
-const { run } = Ember;
-
 const PER_ROW = 11;
 function customEmojis() {
   const list = extendedEmojiList();
@@ -54,7 +52,7 @@ export default Component.extend({
       recentEmojis: this.emojiStore.favorites
     });
 
-    run.scheduleOnce("afterRender", this, function() {
+    schedule("afterRender", this, function() {
       this._bindEvents();
       this._loadCategoriesEmojis();
       this._positionPicker();
@@ -110,7 +108,7 @@ export default Component.extend({
   filterChanged() {
     this.$filter.find(".clear-filter").toggle(!_.isEmpty(this.filter));
     const filterDelay = this.site.isMobileDevice ? 400 : INPUT_DELAY;
-    run.debounce(this, this._filterEmojisList, filterDelay);
+    debounce(this, this._filterEmojisList, filterDelay);
   },
 
   @observes("selectedDiversity")
@@ -309,11 +307,11 @@ export default Component.extend({
 
   _bindResizing() {
     $(window).on("resize", () => {
-      run.throttle(this, this._positionPicker, 16);
+      throttle(this, this._positionPicker, 16);
     });
 
     $("#reply-control").on("div-resizing", () => {
-      run.throttle(this, this._positionPicker, 16);
+      throttle(this, this._positionPicker, 16);
     });
   },
 
@@ -376,7 +374,7 @@ export default Component.extend({
 
   _bindSectionsScroll() {
     let onScroll = () => {
-      run.debounce(this, this._checkVisibleSection, 50);
+      debounce(this, this._checkVisibleSection, 50);
     };
 
     this.$list.on("scroll", onScroll);
diff --git a/app/assets/javascripts/discourse/components/expanding-text-area.js b/app/assets/javascripts/discourse/components/expanding-text-area.js
index ca215cc..94c976c 100644
--- a/app/assets/javascripts/discourse/components/expanding-text-area.js
+++ b/app/assets/javascripts/discourse/components/expanding-text-area.js
@@ -1,12 +1,12 @@
 import { TextArea } from "@ember/component";
-import { scheduleOnce } from "@ember/runloop";
+import { schedule } from "@ember/runloop";
 import { on, observes } from "discourse-common/utils/decorators";
 import autosize from "discourse/lib/autosize";
 
 export default TextArea.extend({
   @on("didInsertElement")
   _startWatching() {
-    scheduleOnce("afterRender", () => {
+    schedule("afterRender", () => {
       $(this.element).focus();
       autosize(this.element);
     });

[... diff too long, it was truncated ...]

GitHub sha: 5e244364

This commit appears in #9428 which was approved by eviltrout. It was merged by jjaffeux.