Revert Ember.run refactors

This reverts commit 5ca60fcb6b.
This commit is contained in:
Robin Ward 2019-10-29 17:10:47 -04:00
parent cfa5d123a3
commit fcb1ca52f9
153 changed files with 319 additions and 493 deletions

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import debounce from "discourse/lib/debounce";
import { renderSpinner } from "discourse/helpers/loading-spinner";
@ -54,7 +53,7 @@ export default Component.extend(
// force rerender
this.rerenderBuffer();
scheduleOnce("afterRender", this, this._scrollDown);
Ember.run.scheduleOnce("afterRender", this, this._scrollDown);
}, 150),
buildBuffer(buffer) {

View File

@ -1,5 +1,3 @@
import { debounce } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import { number } from "discourse/lib/formatter";
import loadScript from "discourse/lib/load-script";
@ -13,7 +11,7 @@ export default Component.extend({
this._super(...arguments);
this.resizeHandler = () =>
debounce(this, this._scheduleChartRendering, 500);
Ember.run.debounce(this, this._scheduleChartRendering, 500);
},
didInsertElement() {
@ -33,11 +31,11 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
debounce(this, this._scheduleChartRendering, 100);
Ember.run.debounce(this, this._scheduleChartRendering, 100);
},
_scheduleChartRendering() {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
this._renderChart(
this.model,
this.element && this.element.querySelector(".chart-canvas")

View File

@ -1,5 +1,3 @@
import { debounce } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import { number } from "discourse/lib/formatter";
import loadScript from "discourse/lib/load-script";
@ -11,7 +9,7 @@ export default Component.extend({
this._super(...arguments);
this.resizeHandler = () =>
debounce(this, this._scheduleChartRendering, 500);
Ember.run.debounce(this, this._scheduleChartRendering, 500);
},
didInsertElement() {
@ -31,11 +29,11 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
debounce(this, this._scheduleChartRendering, 100);
Ember.run.debounce(this, this._scheduleChartRendering, 100);
},
_scheduleChartRendering() {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
if (!this.element) {
return;
}

View File

@ -1,5 +1,4 @@
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import Component from "@ember/component";
import ReportLoader from "discourse/lib/reports-loader";
import { exportEntity } from "discourse/lib/export-csv";
@ -314,7 +313,7 @@ export default Component.extend({
this.setProperties({ isLoading: true, rateLimitationString: null });
next(() => {
Ember.run.next(() => {
let payload = this._buildPayload(["prev_period"]);
const callback = response => {

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { fmt } from "discourse/lib/computed";
@ -84,7 +83,7 @@ export default Component.extend({
toggleMaximize: function() {
this.toggleProperty("maximized");
next(() => this.appEvents.trigger("ace:resize"));
Ember.run.next(() => this.appEvents.trigger("ace:resize"));
},
onlyOverriddenChanged(value) {

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import UserField from "admin/models/user-field";
import { bufferedProperty } from "discourse/mixins/buffered-content";
@ -29,7 +28,7 @@ export default Component.extend(bufferedProperty("userField"), {
@observes("editing")
_focusOnEdit() {
if (this.editing) {
scheduleOnce("afterRender", this, "_focusName");
Ember.run.scheduleOnce("afterRender", this, "_focusName");
}
},

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import { default as loadScript, loadCSS } from "discourse/lib/load-script";
@ -38,7 +37,7 @@ export default Component.extend({
didInsertElement() {
loadScript("/javascripts/spectrum.js").then(() => {
loadCSS("/javascripts/spectrum.css").then(() => {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(this.element.querySelector(".picker"))
.spectrum({ color: "#" + this.hexValue })
.on("change.spectrum", (me, color) => {
@ -48,7 +47,7 @@ export default Component.extend({
});
});
});
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
this.hexValueChanged();
});
}

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import { bufferedProperty } from "discourse/mixins/buffered-content";
import computed from "ember-addons/ember-computed-decorators";
@ -15,7 +14,7 @@ export default Component.extend(bufferedProperty("host"), {
@on("didInsertElement")
@observes("editing")
_focusOnInput() {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
this.element.querySelector(".host-name").focus();
});
},

View File

@ -1,5 +1,4 @@
import EmberObject from "@ember/object";
import { later } from "@ember/runloop";
import Component from "@ember/component";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { ajax } from "discourse/lib/ajax";
@ -79,7 +78,7 @@ export default Component.extend({
$(document.body).append($copyRange);
if (copyText(text, $copyRange[0])) {
this.set("copied", true);
later(() => this.set("copied", false), 2000);
Ember.run.later(() => this.set("copied", false), 2000);
}
$copyRange.remove();
},

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
@ -24,7 +23,7 @@ export default Component.extend({
// If we switch to edit mode, jump to the edit textarea
if (postAction === "edit") {
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
let elem = this.element;
let body = elem.closest(".modal-body");
body.scrollTop(body.height());

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { fmt } from "discourse/lib/computed";
@ -21,7 +20,7 @@ export default Component.extend({
},
focusPermalink() {
schedule("afterRender", () =>
Ember.run.schedule("afterRender", () =>
this.element.querySelector(".permalink-url").focus()
);
},
@ -70,7 +69,7 @@ export default Component.extend({
didInsertElement() {
this._super(...arguments);
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(this.element.querySelector(".external-url")).keydown(e => {
// enter key
if (e.keyCode === 13) {

View File

@ -1,5 +1,3 @@
import { schedule } from "@ember/runloop";
import { later } from "@ember/runloop";
import Component from "@ember/component";
import { iconHTML } from "discourse-common/lib/icon-library";
import { bufferedRender } from "discourse-common/lib/buffered-render";
@ -47,16 +45,18 @@ export default Component.extend(
this.resumable.upload();
// mark as uploading
later(() => this.set("isUploading", true));
Ember.run.later(() => this.set("isUploading", true));
});
this.resumable.on("fileProgress", file => {
// update progress
later(() => this.set("progress", parseInt(file.progress() * 100, 10)));
Ember.run.later(() =>
this.set("progress", parseInt(file.progress() * 100, 10))
);
});
this.resumable.on("fileSuccess", file => {
later(() => {
Ember.run.later(() => {
// mark as not uploading anymore
this._reset();
@ -66,7 +66,7 @@ export default Component.extend(
});
this.resumable.on("fileError", (file, message) => {
later(() => {
Ember.run.later(() => {
// mark as not uploading anymore
this._reset();
@ -78,7 +78,7 @@ export default Component.extend(
@on("didInsertElement")
_assignBrowse() {
schedule("afterRender", () =>
Ember.run.schedule("afterRender", () =>
this.resumable.assignBrowse($(this.element))
);
},
@ -117,7 +117,7 @@ export default Component.extend(
click() {
if (this.isUploading) {
this.resumable.cancel();
later(() => this._reset());
Ember.run.later(() => this._reset());
return false;
} else {
return true;

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
/**
A form to create an IP address that will be blocked or whitelisted.
@ -63,7 +62,7 @@ export default Component.extend({
.then(result => {
this.setProperties({ ip_address: "", formSubmitted: false });
this.action(ScreenedIpAddress.create(result.screened_ip_address));
schedule("afterRender", () =>
Ember.run.schedule("afterRender", () =>
this.element.querySelector(".ip-address-input").focus()
);
})
@ -85,7 +84,7 @@ export default Component.extend({
@on("didInsertElement")
_init() {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(this.element.querySelector(".ip-address-input")).keydown(e => {
if (e.keyCode === 13) {
this.send("submit");

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -34,7 +33,7 @@ export default Component.extend({
},
scheduleAnimation() {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
this.animate(true);
});
},

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import WatchedWord from "admin/models/watched-word";
import {
@ -65,7 +64,7 @@ export default Component.extend({
message: I18n.t("admin.watched_words.form.success")
});
this.action(WatchedWord.create(result));
schedule("afterRender", () =>
Ember.run.schedule("afterRender", () =>
this.element.querySelector(".watched-word-input").focus()
);
})
@ -87,7 +86,7 @@ export default Component.extend({
@on("didInsertElement")
_init() {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(this.element.querySelector(".watched-word-input")).keydown(e => {
if (e.keyCode === 13) {
this.send("submit");

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
import Controller from "@ember/controller";
import computed from "ember-addons/ember-computed-decorators";
@ -42,7 +41,7 @@ export default Controller.extend({
);
}
later(() => {
Ember.run.later(() => {
this.set("model.savingStatus", null);
}, 2000);

View File

@ -1,4 +1,3 @@
import { debounce } from "@ember/runloop";
import Controller from "@ember/controller";
import computed from "ember-addons/ember-computed-decorators";
const { get } = Ember;
@ -22,7 +21,7 @@ export default Controller.extend({
actions: {
filterReports(filter) {
debounce(this, this._performFiltering, filter, 250);
Ember.run.debounce(this, this._performFiltering, filter, 250);
}
},

View File

@ -1,5 +1,4 @@
import EmberObject from "@ember/object";
import { scheduleOnce } from "@ember/runloop";
import Controller from "@ember/controller";
import { exportEntity } from "discourse/lib/export-csv";
import { outputExportResult } from "discourse/lib/export-result";
@ -69,7 +68,7 @@ export default Controller.extend({
},
scheduleRefresh() {
scheduleOnce("afterRender", this, this._refresh);
Ember.run.scheduleOnce("afterRender", this, this._refresh);
},
actions: {

View File

@ -1,4 +1,3 @@
import { debounce } from "@ember/runloop";
import Controller from "@ember/controller";
let lastSearch;
@ -28,14 +27,14 @@ export default Controller.extend({
toggleOverridden() {
this.toggleProperty("overridden");
this.set("searching", true);
debounce(this, this._performSearch, 400);
Ember.run.debounce(this, this._performSearch, 400);
},
search() {
const q = this.q;
if (q !== lastSearch) {
this.set("searching", true);
debounce(this, this._performSearch, 400);
Ember.run.debounce(this, this._performSearch, 400);
lastSearch = q;
}
}

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import GrantBadgeController from "discourse/mixins/grant-badge-controller";
@ -72,7 +71,7 @@ export default Controller.extend(GrantBadgeController, {
).then(
() => {
this.set("badgeReason", "");
next(() => {
Ember.run.next(() => {
// Update the selected badge ID after the combobox has re-rendered.
const newSelectedBadge = this.grantableBadges[0];
if (newSelectedBadge) {

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import computed from "ember-addons/ember-computed-decorators";
@ -52,7 +51,7 @@ export default Controller.extend({
if (a) {
a.words.unshiftObject(arg);
a.incrementProperty("count");
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
// remove from other actions lists
let match = null;
this.get("adminWatchedWords.model").forEach(action => {

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
// Ember 2.0 removes buffered rendering, but we can still implement it ourselves.
// In the long term we'll want to remove this.
@ -14,7 +13,7 @@ const Mixin = {
},
rerenderBuffer() {
scheduleOnce("render", this, this._customRender);
Ember.run.scheduleOnce("render", this, this._customRender);
}
};

View File

@ -1,11 +1,10 @@
import { bind } from "@ember/runloop";
import { getOwner } from "discourse-common/lib/get-owner";
export default Ember.Mixin.create({
ready() {
this._super(...arguments);
this._onChangeHandler = bind(this, this._onChange);
this._onChangeHandler = Ember.run.bind(this, this._onChange);
// Default to true
Discourse.set("hasFocus", true);

View File

@ -14,29 +14,11 @@ var define, requirejs;
"@ember/object": { default: Ember.Object },
"@ember/object/proxy": { default: Ember.ObjectProxy },
"@ember/routing/route": { default: Ember.Route },
"@ember/runloop": {
bind: Ember.run.bind,
cancel: Ember.run.cancel,
debounce: Ember.testing ? Ember.run : Ember.run.debounce,
later: Ember.run.later,
next: Ember.run.next,
once: Ember.run.once,
run: Ember.run,
schedule: Ember.run.schedule,
scheduleOnce: Ember.run.scheduleOnce,
throttle: Ember.run.throttle
},
"@ember/service": {
default: Ember.Service,
inject: Ember.inject.service
}
};
} else if (typeof __PRETTY_TEXT !== "undefined") {
// This is a hack because our server side code includes the pretty_text bundle
// which relies on ember now that we're using modules properly.
// The proper fix would be to move the upload urls code out of the pretty text
// bundle and remove this code. It should never be called;
EMBER_MODULES["@ember/runloop"] = {};
}
var _isArray;

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import { observes } from "ember-addons/ember-computed-decorators";
@ -27,7 +26,7 @@ export default Component.extend({
@observes("category.fullSlug", "tags")
refreshClass() {
scheduleOnce("afterRender", this, this._updateClass);
Ember.run.scheduleOnce("afterRender", this, this._updateClass);
},
_removeClass() {

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import debounce from "discourse/lib/debounce";
import { searchForTerm } from "discourse/lib/search";
@ -58,7 +57,9 @@ export default Component.extend({
chooseMessage(message) {
const messageId = Ember.get(message, "id");
this.set("selectedTopicId", messageId);
next(() => $(`#choose-message-${messageId}`).prop("checked", "true"));
Ember.run.next(() =>
$(`#choose-message-${messageId}`).prop("checked", "true")
);
return false;
}
}

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import debounce from "discourse/lib/debounce";
import { searchForTerm } from "discourse/lib/search";
@ -63,7 +62,7 @@ export default Component.extend({
actions: {
chooseTopic(topic) {
this.set("selectedTopicId", topic.id);
next(() => {
Ember.run.next(() => {
document.getElementById(`choose-topic-${topic.id}`).checked = true;
});
return false;

View File

@ -1,8 +1,3 @@
import { throttle } from "@ember/runloop";
import { run } from "@ember/runloop";
import { cancel } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { later } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -65,7 +60,7 @@ export default Component.extend(KeyEnterEscape, {
"composer.canEditTopicFeaturedLink"
)
resize() {
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
if (!this.element || this.isDestroying || this.isDestroyed) {
return;
}
@ -83,8 +78,8 @@ export default Component.extend(KeyEnterEscape, {
// One second from now, check to see if the last key was hit when
// we recorded it. If it was, the user paused typing.
cancel(this._lastKeyTimeout);
this._lastKeyTimeout = later(() => {
Ember.run.cancel(this._lastKeyTimeout);
this._lastKeyTimeout = Ember.run.later(() => {
if (lastKeyUp !== this._lastKeyUp) {
return;
}
@ -121,7 +116,7 @@ export default Component.extend(KeyEnterEscape, {
const throttledPerformDrag = (event => {
event.preventDefault();
throttle(this, performDrag, event, THROTTLE_RATE);
Ember.run.throttle(this, performDrag, event, THROTTLE_RATE);
}).bind(this);
const endDrag = () => {
@ -158,7 +153,7 @@ export default Component.extend(KeyEnterEscape, {
this._super(...arguments);
this.setupComposerResizeEvents();
const resize = () => run(() => this.resize());
const resize = () => Ember.run(() => this.resize());
const triggerOpen = () => {
if (this.get("composer.composeState") === Composer.OPEN) {
this.appEvents.trigger("composer:opened");

View File

@ -1,8 +1,3 @@
import { throttle } from "@ember/runloop";
import { next } from "@ember/runloop";
import { debounce } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { later } from "@ember/runloop";
import Component from "@ember/component";
import userSearch from "discourse/lib/user-search";
import {
@ -188,7 +183,7 @@ export default Component.extend({
transformComplete: v => v.username || v.name,
afterComplete() {
// ensures textarea scroll position is correct
scheduleOnce("afterRender", () => $input.blur().focus());
Ember.run.scheduleOnce("afterRender", () => $input.blur().focus());
}
});
}
@ -197,7 +192,13 @@ export default Component.extend({
this._initInputPreviewSync($input, $preview);
} else {
$input.on("scroll", () =>
throttle(this, this._syncEditorAndPreviewScroll, $input, $preview, 20)
Ember.run.throttle(
this,
this._syncEditorAndPreviewScroll,
$input,
$preview,
20
)
);
}
@ -315,7 +316,7 @@ export default Component.extend({
this.appEvents.on(event, this, this._resetShouldBuildScrollMap);
});
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
$input.on("touchstart mouseenter", () => {
if (!$preview.is(":visible")) return;
$preview.off("scroll");
@ -341,7 +342,7 @@ export default Component.extend({
this.set("shouldBuildScrollMap", false);
}
throttle(this, $callback, $input, $preview, this.scrollMap, 20);
Ember.run.throttle(this, $callback, $input, $preview, this.scrollMap, 20);
},
_teardownInputPreviewSync() {
@ -558,7 +559,7 @@ export default Component.extend({
},
_warnMentionedGroups($preview) {
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
var found = this.warnedGroupMentions || [];
$preview.find(".mention-group.notify").each((idx, e) => {
const $e = $(e);
@ -586,7 +587,7 @@ export default Component.extend({
return;
}
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
let found = this.warnedCannotSeeMentions || [];
$preview.find(".mention.cannot-see").each((idx, e) => {
@ -596,7 +597,7 @@ export default Component.extend({
if (found.indexOf(name) === -1) {
// add a delay to allow for typing, so you don't open the warning right away
// previously we would warn after @bob even if you were about to mention @bob2
later(
Ember.run.later(
this,
() => {
if (
@ -617,7 +618,7 @@ export default Component.extend({
},
_resetUpload(removePlaceholder) {
next(() => {
Ember.run.next(() => {
if (this._validUploads > 0) {
this._validUploads--;
}
@ -896,9 +897,9 @@ export default Component.extend({
@on("willDestroyElement")
_composerClosed() {
this.appEvents.trigger("composer:will-close");
next(() => {
Ember.run.next(() => {
// need to wait a bit for the "slide down" transition of the composer
later(
Ember.run.later(
() => this.appEvents.trigger("composer:closed"),
Ember.testing ? 0 : 400
);
@ -969,7 +970,7 @@ export default Component.extend({
// Paint mentions
const unseenMentions = linkSeenMentions($preview, this.siteSettings);
if (unseenMentions.length) {
debounce(
Ember.run.debounce(
this,
this._renderUnseenMentions,
$preview,
@ -984,7 +985,7 @@ export default Component.extend({
// Paint category hashtags
const unseenCategoryHashtags = linkSeenCategoryHashtags($preview);
if (unseenCategoryHashtags.length) {
debounce(
Ember.run.debounce(
this,
this._renderUnseenCategoryHashtags,
$preview,
@ -997,7 +998,7 @@ export default Component.extend({
if (this.siteSettings.tagging_enabled) {
const unseenTagHashtags = linkSeenTagHashtags($preview);
if (unseenTagHashtags.length) {
debounce(
Ember.run.debounce(
this,
this._renderUnseenTagHashtags,
$preview,
@ -1008,7 +1009,7 @@ export default Component.extend({
}
// Paint oneboxes
debounce(
Ember.run.debounce(
this,
() => {
const oneboxes = {};

View File

@ -1,5 +1,4 @@
import EmberObject from "@ember/object";
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import LinkLookup from "discourse/lib/link-lookup";
@ -25,7 +24,7 @@ export default Component.extend({
this.appEvents.on("composer:find-similar", this, this._findSimilar);
this.appEvents.on("composer-messages:close", this, this._closeTop);
this.appEvents.on("composer-messages:create", this, this._create);
scheduleOnce("afterRender", this, this.reset);
Ember.run.scheduleOnce("afterRender", this, this.reset);
},
willDestroyElement() {

View File

@ -1,6 +1,3 @@
import { next } from "@ember/runloop";
import { debounce } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -27,7 +24,7 @@ export default Component.extend({
}
if (this.get("composer.titleLength") > 0) {
debounce(this, this._titleChanged, 10);
Ember.run.debounce(this, this._titleChanged, 10);
}
},
@ -82,13 +79,13 @@ export default Component.extend({
}
if (Ember.testing) {
next(() =>
Ember.run.next(() =>
// not ideal but we don't want to run this in current
// runloop to avoid an error in console
this._checkForUrl()
);
} else {
debounce(this, this._checkForUrl, 500);
Ember.run.debounce(this, this._checkForUrl, 500);
}
},
@ -137,14 +134,14 @@ export default Component.extend({
})
.finally(() => {
this.set("composer.loading", false);
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(this.element.querySelector("input")).putCursorAtEnd();
});
});
} else {
this._updatePost(loadOnebox);
this.set("composer.loading", false);
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(this.element.querySelector("input")).putCursorAtEnd();
});
}

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -77,7 +76,7 @@ export default Component.extend({
toggleSelector() {
this.set("showSelector", true);
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(this.element)
.find("input")
.focus();

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import { cookAsync } from "discourse/lib/text";
import { ajax } from "discourse/lib/ajax";
@ -13,7 +12,7 @@ const CookText = Component.extend({
this.set("cooked", cooked);
// no choice but to defer this cause
// pretty text may only be loaded now
next(() =>
Ember.run.next(() =>
window
.requireModule("pretty-text/upload-short-url")
.resolveAllShortUrls(ajax)

View File

@ -1,8 +1,3 @@
import { next } from "@ember/runloop";
import { debounce } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { later } from "@ember/runloop";
import { inject as service } from "@ember/service";
import Component from "@ember/component";
/*global Mousetrap:true */
@ -254,7 +249,7 @@ export default Component.extend({
this._applyEmojiAutocomplete($editorInput);
this._applyCategoryHashtagAutocomplete($editorInput);
scheduleOnce("afterRender", this, this._readyNow);
Ember.run.scheduleOnce("afterRender", this, this._readyNow);
const mouseTrap = Mousetrap(this.element.querySelector(".d-editor-input"));
const shortcuts = this.get("toolbar.shortcuts");
@ -353,7 +348,7 @@ export default Component.extend({
return;
}
this.set("preview", cooked);
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
if (this._state !== "inDOM") {
return;
}
@ -377,7 +372,7 @@ export default Component.extend({
if (Ember.testing) {
this._updatePreview();
} else {
debounce(this, this._updatePreview, 30);
Ember.run.debounce(this, this._updatePreview, 30);
}
},
@ -437,14 +432,17 @@ export default Component.extend({
emojiPickerIsActive: true
});
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
const filterInput = document.querySelector(
".emoji-picker input[name='filter']"
);
if (filterInput) {
filterInput.value = v.term;
later(() => filterInput.dispatchEvent(new Event("input")), 50);
Ember.run.later(
() => filterInput.dispatchEvent(new Event("input")),
50
);
}
});
@ -549,7 +547,7 @@ export default Component.extend({
},
_selectText(from, length) {
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
const textarea = this.element.querySelector("textarea.d-editor-input");
const $textarea = $(textarea);
const oldScrollPos = $textarea.scrollTop();
@ -558,7 +556,7 @@ export default Component.extend({
}
textarea.selectionStart = from;
textarea.selectionEnd = from + length;
next(() => $textarea.trigger("change"));
Ember.run.next(() => $textarea.trigger("change"));
$textarea.scrollTop(oldScrollPos);
});
},
@ -787,7 +785,7 @@ export default Component.extend({
$textarea.val(value);
$textarea.prop("selectionStart", insert.length);
$textarea.prop("selectionEnd", insert.length);
next(() => $textarea.trigger("change"));
Ember.run.next(() => $textarea.trigger("change"));
this._focusTextArea();
},
@ -888,7 +886,7 @@ export default Component.extend({
// ensures textarea scroll position is correct
_focusTextArea() {
const textarea = this.element.querySelector("textarea.d-editor-input");
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
textarea.blur();
textarea.focus();
});

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
export default Component.extend({
classNames: ["modal-body"],
@ -15,7 +14,7 @@ export default Component.extend({
fixedParent.modal("show");
}
scheduleOnce("afterRender", this, this._afterFirstRender);
Ember.run.scheduleOnce("afterRender", this, this._afterFirstRender);
this.appEvents.on("modal-body:flash", this, "_flash");
this.appEvents.on("modal-body:clearFlash", this, "_clearFlash");
},

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import { on } from "ember-addons/ember-computed-decorators";
import Component from "@ember/component";
@ -33,11 +32,11 @@ export default Component.extend({
setUp() {
$("html").on("keydown.discourse-modal", e => {
if (e.which === 27 && this.dismissable) {
next(() => $(".modal-header button.modal-close").click());
Ember.run.next(() => $(".modal-header button.modal-close").click());
}
if (e.which === 13 && this.triggerClickOnEnter(e)) {
next(() => $(".modal-footer .btn-primary").click());
Ember.run.next(() => $(".modal-footer .btn-primary").click());
}
});

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
/* global Pikaday:true */
import loadScript from "discourse/lib/load-script";
@ -38,7 +37,7 @@ export default Component.extend({
_loadPikadayPicker(container) {
loadScript("/javascripts/pikaday.js").then(() => {
next(() => {
Ember.run.next(() => {
const default_opts = {
field: this.element.querySelector(".date-picker"),
container: container || this.element,

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
/* global Pikaday:true */
import loadScript from "discourse/lib/load-script";
@ -31,7 +30,7 @@ export default Component.extend({
_loadPikadayPicker(container) {
loadScript("/javascripts/pikaday.js").then(() => {
next(() => {
Ember.run.next(() => {
const options = {
field: this.element.querySelector(".date-picker"),
container: container || null,

View File

@ -1,7 +1,3 @@
import { throttle } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { later } from "@ember/runloop";
import Component from "@ember/component";
import DiscourseURL from "discourse/lib/url";
import AddArchetypeClass from "discourse/mixins/add-archetype-class";
@ -54,13 +50,13 @@ export default Component.extend(
const enteredAt = this.enteredAt;
if (enteredAt && this.lastEnteredAt !== enteredAt) {
this._lastShowTopic = null;
schedule("afterRender", () => this.scrolled());
Ember.run.schedule("afterRender", () => this.scrolled());
this.set("lastEnteredAt", enteredAt);
}
},
_highlightPost(postNumber) {
scheduleOnce("afterRender", null, highlight, postNumber);
Ember.run.scheduleOnce("afterRender", null, highlight, postNumber);
},
_hideTopicInHeader() {
@ -82,7 +78,7 @@ export default Component.extend(
this.pauseHeaderTopicUpdate = true;
this._lastShowTopic = true;
later(() => {
Ember.run.later(() => {
this._lastShowTopic = false;
this.pauseHeaderTopicUpdate = false;
}, debounceDuration);
@ -196,7 +192,7 @@ export default Component.extend(
// at the start of the scroll. This feels a lot more snappy compared to waiting
// for the scroll to end if we debounce.
if (this.site.mobileView && this.hasScrolled) {
throttle(
Ember.run.throttle(
this,
this.calculateDirection,
offset,

View File

@ -1,5 +1,3 @@
import { schedule } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import { on, observes } from "ember-addons/ember-computed-decorators";
import LoadMore from "discourse/mixins/load-more";
@ -14,9 +12,11 @@ const DiscoveryTopicsListComponent = Component.extend(UrlRefresh, LoadMore, {
_readjustScrollPosition() {
const scrollTo = this.session.get("topicListScrollPosition");
if (scrollTo && scrollTo >= 0) {
schedule("afterRender", () => $(window).scrollTop(scrollTo + 1));
Ember.run.schedule("afterRender", () =>
$(window).scrollTop(scrollTo + 1)
);
} else {
scheduleOnce("afterRender", this, this.loadMoreUnlessFull);
Ember.run.scheduleOnce("afterRender", this, this.loadMoreUnlessFull);
}
},
@ -38,7 +38,7 @@ const DiscoveryTopicsListComponent = Component.extend(UrlRefresh, LoadMore, {
loadMore() {
Discourse.updateContextCount(0);
this.model.loadMore().then(hasMoreResults => {
schedule("afterRender", () => this.saveScrollPosition());
Ember.run.schedule("afterRender", () => this.saveScrollPosition());
if (!hasMoreResults) {
this.eyeline.flushRest();
} else if ($(window).height() >= $(document).height()) {

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import { propertyEqual } from "discourse/lib/computed";
import computed from "ember-addons/ember-computed-decorators";
@ -21,7 +20,7 @@ export default Component.extend({
didInsertElement() {
this._super(...arguments);
scheduleOnce("afterRender", this, this._addToCollection);
Ember.run.scheduleOnce("afterRender", this, this._addToCollection);
},
_addToCollection: function() {

View File

@ -1,10 +1,9 @@
import { scheduleOnce } from "@ember/runloop";
import { buildCategoryPanel } from "discourse/components/edit-category-panel";
export default buildCategoryPanel("topic-template", {
_activeTabChanged: function() {
if (this.activeTab) {
scheduleOnce("afterRender", () =>
Ember.run.scheduleOnce("afterRender", () =>
this.element.querySelector(".d-editor-input").focus()
);
}

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -74,7 +73,7 @@ export default Component.extend({
@observes("selection")
_updateBasedOnLastPost() {
if (!this.autoClose) {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
this.set("topicTimer.based_on_last_post", false);
});
}

View File

@ -1,11 +1,10 @@
import { scheduleOnce } from "@ember/runloop";
import { on, observes } from "ember-addons/ember-computed-decorators";
import autosize from "discourse/lib/autosize";
export default Ember.TextArea.extend({
@on("didInsertElement")
_startWatching() {
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
$(this.element).focus();
autosize(this.element);
});

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import { observes } from "ember-addons/ember-computed-decorators";
@ -17,6 +16,6 @@ export default Component.extend({
@observes("nameKey")
selectedChanged() {
next(this, this._selectRadio);
Ember.run.next(this, this._selectRadio);
}
});

View File

@ -1,4 +1,3 @@
import { throttle } from "@ember/runloop";
import MountWidget from "discourse/components/mount-widget";
import MobileScrollDirection from "discourse/mixins/mobile-scroll-direction";
import Scrolling from "discourse/mixins/scrolling";
@ -79,7 +78,7 @@ const FooterNavComponent = MountWidget.extend(
const offset = window.pageYOffset || $("html").scrollTop();
throttle(
Ember.run.throttle(
this,
this.calculateDirection,
offset,

View File

@ -1,4 +1,3 @@
import { bind } from "@ember/runloop";
import Component from "@ember/component";
import { on } from "ember-addons/ember-computed-decorators";
import { iconHTML } from "discourse-common/lib/icon-library";
@ -89,10 +88,13 @@ export default Component.extend(
@on("didInsertElement")
_setupLogsNotice() {
this._boundRerenderBuffer = bind(this, this.rerenderBuffer);
this._boundRerenderBuffer = Ember.run.bind(this, this.rerenderBuffer);
LogsNotice.current().addObserver("hidden", this._boundRerenderBuffer);
this._boundResetCurrentProp = bind(this, this._resetCurrentProp);
this._boundResetCurrentProp = Ember.run.bind(
this,
this._resetCurrentProp
);
$(this.element).on(
"click.global-notice",
".alert-logs-notice .close",

View File

@ -1,4 +1,3 @@
import { debounce } from "@ember/runloop";
import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
import { observes } from "ember-addons/ember-computed-decorators";
@ -26,7 +25,7 @@ export default Component.extend({
@observes("model.flair_url")
_loadSVGIcon() {
debounce(this, this._loadIcon, 1000);
Ember.run.debounce(this, this._loadIcon, 1000);
},
_loadIcon() {

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import computed from "ember-addons/ember-computed-decorators";
import UploadMixin from "discourse/mixins/upload";
@ -78,13 +77,13 @@ export default Component.extend(UploadMixin, {
},
_openLightbox() {
next(() =>
Ember.run.next(() =>
$(this.element.querySelector("a.lightbox")).magnificPopup("open")
);
},
_applyLightbox() {
if (this.imageUrl) next(() => lightbox($(this.element)));
if (this.imageUrl) Ember.run.next(() => lightbox($(this.element)));
},
actions: {

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
export default Component.extend({
showInput: false,
@ -6,7 +5,7 @@ export default Component.extend({
click() {
this.onClick();
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(this.element)
.find("input")
.focus();

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
export default Component.extend({
didInsertElement() {
@ -15,7 +14,7 @@ export default Component.extend({
this.set("loginName", $.cookie("email"));
}
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$(
"#login-account-password, #login-account-name, #login-second-factor"
).keydown(e => {

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import { on, observes } from "ember-addons/ember-computed-decorators";
@ -22,7 +21,7 @@ export default Component.extend({
@observes("currentPath")
currentPathChanged() {
this.set("expanded", false);
next(() => this._updateSelectedHtml());
Ember.run.next(() => this._updateSelectedHtml());
},
_updateSelectedHtml() {
@ -42,7 +41,7 @@ export default Component.extend({
toggleExpanded() {
this.toggleProperty("expanded");
next(() => {
Ember.run.next(() => {
if (this.expanded) {
$(window)
.off("click.mobile-nav")

View File

@ -1,5 +1,3 @@
import { cancel } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import { diff, patch } from "virtual-dom";
import { WidgetClickHook } from "discourse/widgets/hooks";
@ -52,7 +50,7 @@ export default Component.extend({
this._rootNode = document.createElement("div");
this.element.appendChild(this._rootNode);
this._timeout = scheduleOnce("render", this, this.rerenderWidget);
this._timeout = Ember.run.scheduleOnce("render", this, this.rerenderWidget);
},
willClearRender() {
@ -70,7 +68,7 @@ export default Component.extend({
const [eventName, caller] = evt;
this.appEvents.off(eventName, this, caller);
});
cancel(this._timeout);
Ember.run.cancel(this._timeout);
},
afterRender() {},
@ -99,13 +97,13 @@ export default Component.extend({
this._renderCallback = callback;
}
scheduleOnce("render", this, this.rerenderWidget);
Ember.run.scheduleOnce("render", this, this.rerenderWidget);
},
buildArgs() {},
rerenderWidget() {
cancel(this._timeout);
Ember.run.cancel(this._timeout);
if (this._rootNode) {
if (!this._widgetClass) {

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -70,7 +69,7 @@ export default Component.extend({
if (this.expanded) {
DiscourseURL.appEvents.on("dom:clean", this, this.ensureDropClosed);
next(() => {
Ember.run.next(() => {
if (!this.expanded) {
return;
}
@ -78,7 +77,7 @@ export default Component.extend({
$(this.element.querySelector(".drop a")).on("click", () => {
this.element.querySelector(".drop").style.display = "none";
next(() => {
Ember.run.next(() => {
if (!this.element || this.isDestroying || this.isDestroyed) {
return;
}

View File

@ -1,4 +1,3 @@
import { bind } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -19,7 +18,10 @@ export default Component.extend({
@on("didInsertElement")
_registerListener() {
this._promptEventHandler = bind(this, this._handleInstallPromptEvent);
this._promptEventHandler = Ember.run.bind(
this,
this._handleInstallPromptEvent
);
window.addEventListener("beforeinstallprompt", this._promptEventHandler);
},

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import debounce from "discourse/lib/debounce";
import { selectedText } from "discourse/lib/utilities";
@ -104,7 +103,7 @@ export default Component.extend({
}
// change the position of the button
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
let top = markerOffset.top;
let left = markerOffset.left + Math.max(0, parentScrollLeft);

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
import Scrolling from "discourse/mixins/scrolling";
@ -20,7 +19,7 @@ export default Component.extend(Scrolling, {
const data = this.session.get(this.trackerName);
if (data && data.position >= 0 && data.tag === this.tag) {
next(() => $(window).scrollTop(data.position + 1));
Ember.run.next(() => $(window).scrollTop(data.position + 1));
}
},

View File

@ -1,6 +1,3 @@
import { next } from "@ember/runloop";
import { debounce } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url";
import MountWidget from "discourse/components/mount-widget";
import { cloak, uncloak } from "discourse/widgets/post-stream";
@ -207,7 +204,7 @@ export default MountWidget.extend({
// will cause the browser to scroll to the top of the document
// in Chrome. This makes sure the scroll works correctly if that
// happens.
next(() => $("html, body").scrollTop(whereY));
Ember.run.next(() => $("html, body").scrollTop(whereY));
}
});
};
@ -273,7 +270,7 @@ export default MountWidget.extend({
},
_scrollTriggered() {
scheduleOnce("afterRender", this, this.scrolled);
Ember.run.scheduleOnce("afterRender", this, this.scrolled);
},
_posted(staged) {
@ -309,12 +306,13 @@ export default MountWidget.extend({
},
_debouncedScroll() {
debounce(this, this._scrollTriggered, 10);
Ember.run.debounce(this, this._scrollTriggered, 10);
},
didInsertElement() {
this._super(...arguments);
const debouncedScroll = () => debounce(this, this._scrollTriggered, 10);
const debouncedScroll = () =>
Ember.run.debounce(this, this._scrollTriggered, 10);
this._previouslyNearby = {};

View File

@ -1,5 +1,3 @@
import { debounce } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import { observes } from "ember-addons/ember-computed-decorators";
import { escapeExpression } from "discourse/lib/utilities";
@ -74,13 +72,13 @@ export default Component.extend({
this._init();
scheduleOnce("afterRender", () => this._update());
Ember.run.scheduleOnce("afterRender", () => this._update());
},
@observes("searchTerm")
_updateOptions() {
this._update();
debounce(this, this._update, 250);
Ember.run.debounce(this, this._update, 250);
},
_init() {

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import { escapeExpression } from "discourse/lib/utilities";
import { default as computed } from "ember-addons/ember-computed-decorators";
@ -48,7 +47,7 @@ export default Component.extend({
this.element.querySelector(".topic-share-url-for-touch a")
);
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
if (!this.capabilities.touch) {
$linkForTouch.parent().remove();

View File

@ -1,5 +1,3 @@
import { bind } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import { wantsNewWindow } from "discourse/lib/intercept-click";
import { longDateNoYear } from "discourse/lib/formatter";
@ -91,7 +89,7 @@ export default Component.extend({
this.set("link", url);
this.set("visible", true);
scheduleOnce("afterRender", this, this._focusUrl);
Ember.run.scheduleOnce("afterRender", this, this._focusUrl);
},
_mouseDownHandler(event) {
@ -156,9 +154,9 @@ export default Component.extend({
@on("init")
_setupHandlers() {
this._boundMouseDownHandler = bind(this, this._mouseDownHandler);
this._boundClickHandler = bind(this, this._clickHandler);
this._boundKeydownHandler = bind(this, this._keydownHandler);
this._boundMouseDownHandler = Ember.run.bind(this, this._mouseDownHandler);
this._boundClickHandler = Ember.run.bind(this, this._clickHandler);
this._boundKeydownHandler = Ember.run.bind(this, this._keydownHandler);
},
didInsertElement() {

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
import Component from "@ember/component";
export default Component.extend({
action: "showCreateAccount",
@ -11,7 +10,10 @@ export default Component.extend({
hideForSession() {
this.session.set("hideSignupCta", true);
this.keyValueStore.setItem("anon-cta-hidden", new Date().getTime());
later(() => this.session.set("showSignupCta", false), 20 * 1000);
Ember.run.later(
() => this.session.set("showSignupCta", false),
20 * 1000
);
}
},

View File

@ -1,6 +1,3 @@
import { cancel } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import { later } from "@ember/runloop";
import MountWidget from "discourse/components/mount-widget";
import { observes } from "ember-addons/ember-computed-decorators";
import Docking from "discourse/mixins/docking";
@ -41,7 +38,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
_animateClosing($panel, menuOrigin, windowWidth) {
$panel.css(menuOrigin, -windowWidth);
this._animate = true;
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
this.eventDispatched("dom:clean", "header");
this._panMenuOffset = 0;
});
@ -225,7 +222,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
this.appEvents.off("header:hide-topic", this, "setTopic");
this.appEvents.off("dom:clean", this, "_cleanDom");
cancel(this._scheduledRemoveAnimate);
Ember.run.cancel(this._scheduledRemoveAnimate);
window.cancelAnimationFrame(this._scheduledMovingAnimation);
},
@ -349,7 +346,7 @@ const SiteHeaderComponent = MountWidget.extend(Docking, PanEvents, {
if (this._animate) {
$panel.addClass("animate");
$headerCloak.addClass("animate");
this._scheduledRemoveAnimate = later(() => {
this._scheduledRemoveAnimate = Ember.run.later(() => {
$panel.removeClass("animate");
$headerCloak.removeClass("animate");
}, 200);

View File

@ -1,9 +1,8 @@
import { next } from "@ember/runloop";
import Component from "@ember/component";
export default Component.extend({
didInsertElement() {
this._super(...arguments);
next(null, () => {
Ember.run.next(null, () => {
const $this = $(this.element);
if ($this) {

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import { isNumeric } from "discourse/lib/utilities";
@ -37,7 +36,7 @@ export default Component.extend({
this._processMinutesChange(value);
}
schedule("afterRender", () => (event.target.value = value));
Ember.run.schedule("afterRender", () => (event.target.value = value));
}
},

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import DiscourseURL from "discourse/lib/url";
import CleansUp from "discourse/mixins/cleans-up";
@ -78,7 +77,7 @@ export default Component.extend(CleansUp, {
this.setProperties({ topic: data.topic, visible: true });
scheduleOnce("afterRender", this, this._setCSS);
Ember.run.scheduleOnce("afterRender", this, this._setCSS);
$("html")
.off("mousedown.topic-entrance")

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -70,7 +69,9 @@ export default Component.extend(LoadMore, {
let scrollTo = this.session.get("topicListScrollPosition");
if (scrollTo && scrollTo >= 0) {
schedule("afterRender", () => $(window).scrollTop(scrollTo + 1));
Ember.run.schedule("afterRender", () =>
$(window).scrollTop(scrollTo + 1)
);
}
},

View File

@ -1,6 +1,4 @@
import EmberObject from "@ember/object";
import { scheduleOnce } from "@ember/runloop";
import { later } from "@ember/runloop";
import Component from "@ember/component";
import { observes } from "ember-addons/ember-computed-decorators";
import showModal from "discourse/lib/show-modal";
@ -54,7 +52,7 @@ export default Component.extend(PanEvents, {
},
_checkSize() {
scheduleOnce("afterRender", this, this._performCheckSize);
Ember.run.scheduleOnce("afterRender", this, this._performCheckSize);
},
// we need to store this so topic progress has something to init with
@ -90,7 +88,7 @@ export default Component.extend(PanEvents, {
composerOpened() {
this.set("composerOpen", true);
// we need to do the check after animation is done
later(() => this._checkSize(), 500);
Ember.run.later(() => this._checkSize(), 500);
},
composerClosed() {
@ -101,7 +99,7 @@ export default Component.extend(PanEvents, {
_collapseFullscreen() {
if (this.get("info.topicProgressExpanded")) {
$(".timeline-fullscreen").removeClass("show");
later(() => {
Ember.run.later(() => {
if (!this.element || this.isDestroying || this.isDestroyed) {
return;
}
@ -139,7 +137,7 @@ export default Component.extend(PanEvents, {
} else if (offset <= 0) {
$timelineContainer.css("bottom", "");
} else {
later(() => this._handlePanDone(offset, event), 20);
Ember.run.later(() => this._handlePanDone(offset, event), 20);
}
},

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import Component from "@ember/component";
import {
default as computed,
@ -74,7 +73,7 @@ export default Component.extend({
@observes("postStream.stream.[]")
_updateBar() {
scheduleOnce("afterRender", this, this._updateProgressBar);
Ember.run.scheduleOnce("afterRender", this, this._updateProgressBar);
},
_topicScrolled(event) {
@ -101,11 +100,16 @@ export default Component.extend({
const prevEvent = this.prevEvent;
if (prevEvent) {
scheduleOnce("afterRender", this, this._topicScrolled, prevEvent);
Ember.run.scheduleOnce(
"afterRender",
this,
this._topicScrolled,
prevEvent
);
} else {
scheduleOnce("afterRender", this, this._updateProgressBar);
Ember.run.scheduleOnce("afterRender", this, this._updateProgressBar);
}
scheduleOnce("afterRender", this, this._dock);
Ember.run.scheduleOnce("afterRender", this, this._dock);
},
willDestroyElement() {

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import MountWidget from "discourse/components/mount-widget";
import Docking from "discourse/mixins/docking";
import { observes } from "ember-addons/ember-computed-decorators";
@ -95,7 +94,7 @@ export default MountWidget.extend(Docking, {
this._super(...arguments);
if (this.fullscreen && !this.addShowClass) {
next(() => {
Ember.run.next(() => {
this.set("addShowClass", true);
this.queueRerender();
});

View File

@ -1,5 +1,3 @@
import { cancel } from "@ember/runloop";
import { later } from "@ember/runloop";
import Component from "@ember/component";
import { iconHTML } from "discourse-common/lib/icon-library";
import { bufferedRender } from "discourse-common/lib/buffered-render";
@ -87,7 +85,11 @@ export default Component.extend(
// TODO Sam: concerned this can cause a heavy rerender loop
if (!Ember.testing) {
this._delayedRerender = later(this, this.rerender, rerenderDelay);
this._delayedRerender = Ember.run.later(
this,
this.rerender,
rerenderDelay
);
}
}
},
@ -108,7 +110,7 @@ export default Component.extend(
$(this.element).off("click.topic-timer-remove", this.removeTopicTimer);
if (this._delayedRerender) {
cancel(this._delayedRerender);
Ember.run.cancel(this._delayedRerender);
}
},

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Component from "@ember/component";
import LoadMore from "discourse/mixins/load-more";
import ClickTrack from "discourse/lib/click-track";
@ -24,7 +23,7 @@ export default Component.extend(LoadMore, {
classNames: ["user-stream"],
_scrollTopOnModelChange: function() {
schedule("afterRender", () => $(document).scrollTop(0));
Ember.run.schedule("afterRender", () => $(document).scrollTop(0));
}.observes("stream.user.id"),
_inserted: Ember.on("didInsertElement", function() {

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { ajax } from "discourse/lib/ajax";
@ -25,7 +24,7 @@ export default Controller.extend(ModalFunctionality, {
highlightSecure() {
this.send("closeModal");
next(() => {
Ember.run.next(() => {
const $prefPasswordDiv = $(".pref-password");
$prefPasswordDiv.addClass("highlighted");

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
@ -54,7 +53,7 @@ export default Controller.extend(ModalFunctionality, {
if (this.get("topicController.multiSelect")) {
this.topicController.send("toggleMultiSelect");
}
next(() =>
Ember.run.next(() =>
DiscourseURL.routeTo(this.get("topicController.model.url"))
);
},

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
@ -48,7 +47,7 @@ export default Controller.extend(ModalFunctionality, {
.then(() => {
this.send("closeModal");
this.setProperties({ date: "", time: "", saving: false });
next(() => DiscourseURL.routeTo(topic.url));
Ember.run.next(() => DiscourseURL.routeTo(topic.url));
})
.catch(() =>
this.flash(I18n.t("topic.change_timestamp.error"), "alert-error")

View File

@ -1,4 +1,3 @@
import { debounce } from "@ember/runloop";
import { inject as service } from "@ember/service";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
@ -1047,7 +1046,7 @@ export default Controller.extend({
@observes("model.reply", "model.title")
_shouldSaveDraft() {
debounce(this, this._saveDraft, 2000);
Ember.run.debounce(this, this._saveDraft, 2000);
},
@computed("model.categoryId", "lastValidatedAt")

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import Controller from "@ember/controller";
import {
on,
@ -114,7 +113,7 @@ export default Controller.extend({
tryLoading() {
this.set("loading", true);
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
this.lastTransition.retry();
this.set("loading", false);
});

View File

@ -1,6 +1,3 @@
import { debounce } from "@ember/runloop";
import { cancel } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { searchForTerm } from "discourse/lib/search";
@ -18,7 +15,7 @@ export default Controller.extend(ModalFunctionality, {
selectedRow: -1
});
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
const element = document.querySelector(".insert-link");
element.addEventListener("keydown", e => this.keyDown(e));
@ -138,7 +135,7 @@ export default Controller.extend(ModalFunctionality, {
.closest(".modal-inner-container")
.removeEventListener("mousedown", this.mouseDown);
cancel(this._debounced);
Ember.run.cancel(this._debounced);
},
actions: {
@ -177,7 +174,7 @@ export default Controller.extend(ModalFunctionality, {
}
},
search() {
this._debounced = debounce(this, this.triggerSearch, 400);
this._debounced = Ember.run.debounce(this, this.triggerSearch, 400);
}
}
});

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
@ -11,7 +10,7 @@ export default Controller.extend(ModalFunctionality, {
),
onShow() {
next(() => $("#post-jump").focus());
Ember.run.next(() => $("#post-jump").focus());
},
actions: {

View File

@ -1,6 +1,4 @@
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
@ -152,7 +150,7 @@ export default Controller.extend(ModalFunctionality, {
// only need to focus the 2FA input for TOTP
if (!this.showSecurityKey) {
scheduleOnce("afterRender", () =>
Ember.run.scheduleOnce("afterRender", () =>
document
.getElementById("second-factor")
.querySelector("input")
@ -324,7 +322,7 @@ export default Controller.extend(ModalFunctionality, {
const loginError = (errorMsg, className, callback) => {
showModal("login");
next(() => {
Ember.run.next(() => {
if (callback) callback();
this.flash(errorMsg, className || "success");
});

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
@ -93,7 +92,7 @@ export default Controller.extend(ModalFunctionality, {
);
} else if (!this.canSplitTopic) {
this.set("selection", "existing_topic");
next(() => $("#choose-topic-title").focus());
Ember.run.next(() => $("#choose-topic-title").focus());
}
},

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
import Controller from "@ember/controller";
import { default as computed } from "ember-addons/ember-computed-decorators";
import { SECOND_FACTOR_METHODS } from "discourse/models/user";
@ -103,7 +102,7 @@ export default Controller.extend(ModalFunctionality, {
},
_hideCopyMessage() {
later(
Ember.run.later(
() => this.setProperties({ successMessage: null, errorMessage: null }),
2000
);

View File

@ -1,6 +1,4 @@
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { inject } from "@ember/controller";
import Controller from "@ember/controller";
import { bufferedProperty } from "discourse/mixins/buffered-content";
@ -135,7 +133,7 @@ export default Controller.extend(bufferedProperty("model"), {
return;
}
scheduleOnce("afterRender", () => {
Ember.run.scheduleOnce("afterRender", () => {
this.send("showHistory", post, revision);
});
},
@ -1428,7 +1426,7 @@ export default Controller.extend(bufferedProperty("model"), {
// automatically unpin topics when the user reaches the bottom
const max = _.max(postNumbers);
if (topic.get("pinned") && max >= topic.get("highest_post_number")) {
next(() => topic.clearPin());
Ember.run.next(() => topic.clearPin());
}
}
}

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
// Subscribe to "asset-version" change events via the Message Bus
export default {
name: "asset-version",
@ -17,7 +16,7 @@ export default {
if (!timeoutIsSet && Discourse.get("requiresRefresh")) {
// Since we can do this transparently for people browsing the forum
// hold back the message 24 hours.
later(() => {
Ember.run.later(() => {
bootbox.confirm(I18n.t("assets_changed_confirm"), function(result) {
if (result) {
document.location.reload();

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
export default {
name: "auth-complete",
after: "inject-objects",
@ -14,7 +13,7 @@ export default {
if (lastAuthResult) {
const router = container.lookup("router:main");
router.one("didTransition", () => {
next(() =>
Ember.run.next(() =>
Discourse.authenticationComplete(JSON.parse(lastAuthResult))
);
});

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
import Mobile from "discourse/lib/mobile";
import { setResolverOption } from "discourse-common/resolver";
import { isAppWebview, postRNWebviewMessage } from "discourse/lib/utilities";
@ -18,7 +17,7 @@ export default {
setResolverOption("mobileView", Mobile.mobileView);
if (isAppWebview()) {
later(() => {
Ember.run.later(() => {
postRNWebviewMessage(
"headerBg",
$(".d-header").css("background-color")

View File

@ -1,4 +1,3 @@
import { run } from "@ember/runloop";
import pageVisible from "discourse/lib/page-visible";
import logout from "discourse/lib/logout";
@ -97,7 +96,7 @@ export function ajax() {
handleRedirect(data);
handleLogoff(xhr);
run(() => {
Ember.run(() => {
Discourse.Site.currentProp(
"isReadOnly",
!!xhr.getResponseHeader("Discourse-Readonly")
@ -108,7 +107,7 @@ export function ajax() {
data = { result: data, xhr: xhr };
}
run(null, resolve, data);
Ember.run(null, resolve, data);
};
args.error = (xhr, textStatus, errorThrown) => {
@ -129,7 +128,7 @@ export function ajax() {
xhr.jqTextStatus = textStatus;
xhr.requestedUrl = url;
run(null, reject, {
Ember.run(null, reject, {
jqXHR: xhr,
textStatus: textStatus,
errorThrown: errorThrown

View File

@ -1,5 +1,3 @@
import { cancel } from "@ember/runloop";
import { later } from "@ember/runloop";
/**
This is a jQuery plugin to support autocompleting values in our text fields.
@ -45,7 +43,7 @@ export default function(options) {
if (this.length === 0) return;
if (options === "destroy" || options.updateData) {
cancel(inputTimeout);
Ember.run.cancel(inputTimeout);
$(this)
.off("keyup.autocomplete")
@ -404,7 +402,7 @@ export default function(options) {
$(this).on("click.autocomplete", () => closeAutocomplete());
$(this).on("paste.autocomplete", () => {
later(() => me.trigger("keydown"), 50);
Ember.run.later(() => me.trigger("keydown"), 50);
});
function checkTriggerRule(opts) {
@ -457,8 +455,8 @@ export default function(options) {
if (options.allowAny) {
// saves us wiring up a change event as well
cancel(inputTimeout);
inputTimeout = later(function() {
Ember.run.cancel(inputTimeout);
inputTimeout = Ember.run.later(function() {
if (inputSelectedItems.length === 0) {
inputSelectedItems.push("");
}

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
function _clean() {
if (window.MiniProfiler) {
window.MiniProfiler.pageTransition();
@ -36,5 +35,5 @@ function _clean() {
}
export function cleanDOM() {
scheduleOnce("afterRender", _clean);
Ember.run.scheduleOnce("afterRender", _clean);
}

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
import { ajax } from "discourse/lib/ajax";
import DiscourseURL from "discourse/lib/url";
import { wantsNewWindow } from "discourse/lib/intercept-click";
@ -135,7 +134,7 @@ export default {
$link.attr("href", null);
$link.data("auto-route", true);
later(() => {
Ember.run.later(() => {
$link.removeClass("no-href");
$link.attr("href", $link.data("href"));
$link.data("href", null);

View File

@ -1,4 +1,3 @@
import { debounce } from "@ember/runloop";
/**
Debounce a Javascript function. This means if it's called many times in a time limit it
should only be executed once (at the end of the limit counted from the last call made).
@ -14,6 +13,6 @@ export default function(func, wait) {
self = this;
args = arguments;
debounce(null, later, wait);
Ember.run.debounce(null, later, wait);
};
}

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url";
import KeyValueStore from "discourse/lib/key-value-store";
import { formatUsername } from "discourse/lib/utilities";
@ -80,7 +79,7 @@ function confirmNotification() {
const clickEventHandler = () => notification.close();
notification.addEventListener("click", clickEventHandler);
later(() => {
Ember.run.later(() => {
notification.close();
notification.removeEventListener("click", clickEventHandler);
}, 10 * 1000);
@ -178,7 +177,7 @@ function onNotification(data) {
}
notification.addEventListener("click", clickEventHandler);
later(() => {
Ember.run.later(() => {
notification.close();
notification.removeEventListener("click", clickEventHandler);
}, 10 * 1000);

View File

@ -1,5 +1,3 @@
import { run } from "@ember/runloop";
import { later } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url";
import Composer from "discourse/models/composer";
import { minimumOffset } from "discourse/lib/offset-calculator";
@ -142,7 +140,7 @@ export default {
quoteReply() {
this.sendToSelectedPost("replyToPost");
// lazy but should work for now
later(() => $(".d-editor .quote").click(), 500);
Ember.run.later(() => $(".d-editor .quote").click(), 500);
return false;
},
@ -212,7 +210,7 @@ export default {
},
showPageSearch(event) {
run(() => {
Ember.run(() => {
this.appEvents.trigger("header:keyboard-trigger", {
type: "page-search",
event
@ -221,7 +219,7 @@ export default {
},
printTopic(event) {
run(() => {
Ember.run(() => {
if ($(".container.posts").length) {
event.preventDefault(); // We need to stop printing the current page in Firefox
this.container.lookup("controller:topic").print();

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import { ajax } from "discourse/lib/ajax";
import { replaceSpan } from "discourse/lib/category-hashtags";
@ -8,7 +7,7 @@ const testedKey = "tested";
const testedClass = `hashtag-${testedKey}`;
function updateFound($hashtags, categorySlugs) {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$hashtags.each((index, hashtag) => {
const categorySlug = categorySlugs[index];
const link = validCategoryHashtags[categorySlug];

View File

@ -1,4 +1,3 @@
import { scheduleOnce } from "@ember/runloop";
import { ajax } from "discourse/lib/ajax";
import { userPath } from "discourse/lib/url";
import { formatUsername } from "discourse/lib/utilities";
@ -40,7 +39,7 @@ const checked = {};
const cannotSee = [];
function updateFound($mentions, usernames) {
scheduleOnce("afterRender", function() {
Ember.run.scheduleOnce("afterRender", function() {
$mentions.each((i, e) => {
const $e = $(e);
const username = usernames[i];

View File

@ -1,4 +1,3 @@
import { schedule } from "@ember/runloop";
import { ajax } from "discourse/lib/ajax";
import { replaceSpan } from "discourse/lib/category-hashtags";
import { TAG_HASHTAG_POSTFIX } from "discourse/lib/tag-hashtags";
@ -8,7 +7,7 @@ const checkedTagHashtags = [];
const testedClass = "tag-hashtag-tested";
function updateFound($hashtags, tagValues) {
schedule("afterRender", () => {
Ember.run.schedule("afterRender", () => {
$hashtags.each((index, hashtag) => {
const tagValue = tagValues[index];
const link = validTagHashtags[tagValue];

View File

@ -1,4 +1,3 @@
import { run } from "@ember/runloop";
import { ajax } from "discourse/lib/ajax";
const _loaded = {};
const _loading = {};
@ -23,7 +22,7 @@ function loadWithTag(path, cb) {
) {
s = s.onload = s.onreadystatechange = null;
if (!abort) {
run(null, cb);
Ember.run(null, cb);
}
}
};

View File

@ -1,4 +1,3 @@
import { next } from "@ember/runloop";
let _started = false;
let cache = {};
let transitionCount = 0;
@ -32,7 +31,7 @@ export function startPageTracking(router, appEvents) {
// Refreshing the title is debounced, so we need to trigger this in the
// next runloop to have the correct title.
next(() => {
Ember.run.next(() => {
let title = Discourse.get("_docTitle");
appEvents.trigger("page:changed", {

View File

@ -1,4 +1,3 @@
import { later } from "@ember/runloop";
import debounce from "discourse/lib/debounce";
import {
safariHacksDisabled,
@ -95,7 +94,10 @@ function positioningWorkaround($fixedElement) {
if (!iOSWithVisualViewport()) {
fixedElement.style.height = oldHeight;
later(() => $(fixedElement).removeClass("no-transition"), 500);
Ember.run.later(
() => $(fixedElement).removeClass("no-transition"),
500
);
}
$(window).scrollTop(originalScrollTop);

View File

@ -1,4 +1,3 @@
import { bind } from "@ember/runloop";
import { ajax } from "discourse/lib/ajax";
// We use this class to track how long posts in a topic are on the screen.
@ -27,7 +26,7 @@ export default class {
// Create an interval timer if we don't have one.
if (!this._interval) {
this._interval = setInterval(() => this.tick(), 1000);
this._boundScrolled = bind(this, this.scrolled);
this._boundScrolled = Ember.run.bind(this, this.scrolled);
$(window).on("scroll.screentrack", this._boundScrolled);
}

Some files were not shown because too many files have changed in this diff Show More