Skip to content

A platform for community discussion. Free, open, simple.

DEV: replaces setTimeout by Ember.run.later (#6618)

Joffrey JAFFEUX907cf3ee2fe9
diff --git a/app/assets/javascripts/admin/controllers/admin-customize-colors-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-customize-colors-show.js.es6
index ca62835a04c..9b83dbaeb89 100644
--- a/app/assets/javascripts/admin/controllers/admin-customize-colors-show.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-customize-colors-show.js.es6
@@ -40,7 +40,7 @@ export default Ember.Controller.extend({
);
}
- setTimeout(() => {
+ Ember.run.later(() => {
this.set("model.savingStatus", null);
}, 2000);
diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6
index 1227e864b34..ce9b6a5f6e4 100644
--- a/app/assets/javascripts/discourse/components/composer-editor.js.es6
+++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6
@@ -786,7 +786,7 @@ export default Ember.Component.extend({
// The paste doesn't finish immediately and we don't have any onpaste
// event, so wait for 100ms which _should_ be enough time.
- setTimeout(() => {
+ Ember.run.later(() => {
const pastedImg = contentEditableDiv.find("img");
if (pastedImg.length === 1) {
diff --git a/app/assets/javascripts/discourse/initializers/asset-version.js.es6 b/app/assets/javascripts/discourse/initializers/asset-version.js.es6
index 8a939053562..980e21ee624 100644
--- a/app/assets/javascripts/discourse/initializers/asset-version.js.es6
+++ b/app/assets/javascripts/discourse/initializers/asset-version.js.es6
@@ -16,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.
- setTimeout(function() {
+ Ember.run.later(() => {
bootbox.confirm(I18n.lookup("assets_changed_confirm"), function(
result
) {
diff --git a/app/assets/javascripts/discourse/lib/click-track.js.es6 b/app/assets/javascripts/discourse/lib/click-track.js.es6
index 1ce5493902e..1da282ba480 100644
--- a/app/assets/javascripts/discourse/lib/click-track.js.es6
+++ b/app/assets/javascripts/discourse/lib/click-track.js.es6
@@ -114,7 +114,7 @@ export default {
}
// restore href
- setTimeout(() => {
+ Ember.run.later(() => {
$link.removeClass("no-href");
$link.attr("href", $link.data("href"));
$link.data("href", null);
diff --git a/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 b/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6
index 06264d5c199..5b26fce0ebc 100644
--- a/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6
+++ b/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6
@@ -79,7 +79,7 @@ function confirmNotification() {
const clickEventHandler = () => notification.close();
notification.addEventListener("click", clickEventHandler);
- setTimeout(() => {
+ Ember.run.later(() => {
notification.close();
notification.removeEventListener("click", clickEventHandler);
}, 10 * 1000);
@@ -177,7 +177,7 @@ function onNotification(data) {
}
notification.addEventListener("click", clickEventHandler);
- setTimeout(function() {
+ Ember.run.later(() => {
notification.close();
notification.removeEventListener("click", clickEventHandler);
}, 10 * 1000);
diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6
index 31f1c9a2140..0e43e1e97dd 100644
--- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6
+++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6
@@ -130,9 +130,7 @@ export default {
quoteReply() {
this.sendToSelectedPost("replyToPost");
// lazy but should work for now
- setTimeout(function() {
- $(".d-editor .quote").click();
- }, 500);
+ Ember.run.later(() => $(".d-editor .quote").click(), 500);
},
goToFirstPost() {
diff --git a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6
index d2e228f299e..8c7c9df7d53 100644
--- a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6
+++ b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6
@@ -86,9 +86,7 @@ function positioningWorkaround($fixedElement) {
fixedElement.style.top = "";
fixedElement.style.height = oldHeight;
- setTimeout(() => {
- $(fixedElement).removeClass("no-transition");
- }, 500);
+ Ember.run.later(() => $(fixedElement).removeClass("no-transition"), 500);
$(window).scrollTop(originalScrollTop);
diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6
index f73c7392ad4..d5d7ff074af 100644
--- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6
+++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6
@@ -395,7 +395,7 @@ export default createWidget("topic-timeline", {
const stream = this.attrs.topic.get("postStream");
// a little debounce to avoid flashing
- setTimeout(() => {
+ Ember.run.later(() => {
if (!this.state.position === pos) {
return;
}