From 375f3feeb8a59d39dccbfde1cbddf8d8ab1ef487 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 20 Dec 2016 10:26:53 +0800 Subject: [PATCH] FIX: Topic featured links not getting oneboxed immediately. --- app/assets/javascripts/pretty-text/oneboxer.js.es6 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/pretty-text/oneboxer.js.es6 b/app/assets/javascripts/pretty-text/oneboxer.js.es6 index 6d068658638..2d3f4270d64 100644 --- a/app/assets/javascripts/pretty-text/oneboxer.js.es6 +++ b/app/assets/javascripts/pretty-text/oneboxer.js.es6 @@ -30,7 +30,7 @@ function loadNext(ajax) { failedCache[url] = true; } }).finally(() => { - timeout = setTimeout(() => loadNext(ajax), timeoutMs); + timeout = Ember.run.later(() => loadNext(ajax), timeoutMs); if (removeLoading) { elem.removeClass('loading-onebox'); elem.data('onebox-loaded'); @@ -67,7 +67,11 @@ export function load(e, refresh, ajax, userId) { loadingQueue.push({ url, refresh, elem, userId }); // Load next url in queue - timeout = timeout || setTimeout(() => loadNext(ajax), 150); + if (timeout) { + return Ember.run.later(() => loadNext(ajax), 150); + } else { + return loadNext(ajax); + } } export function lookupCache(url) {