@@ -471,7 +471,7 @@ class DuckWidget {
471
471
if ( onError ) {
472
472
fbElement . addEventListener ( 'error' , onError , { once : true } )
473
473
}
474
- } , { once : true } )
474
+ } )
475
475
}
476
476
}
477
477
// If this is a login button, show modal if needed
@@ -858,7 +858,7 @@ async function replaceClickToLoadElements (targetElement) {
858
858
* the page.
859
859
* @param {unblockClickToLoadContentRequest } message
860
860
* @see {@link ddg-ctp-unblockClickToLoadContent-complete } for the response handler.
861
- * @return {Promise<any > }
861
+ * @returns {Promise<void > }
862
862
*/
863
863
function unblockClickToLoadContent ( message ) {
864
864
return ctl . messaging . request ( 'unblockClickToLoadContent' , message )
@@ -870,9 +870,9 @@ function unblockClickToLoadContent (message) {
870
870
* shown.
871
871
* @param {string } entity
872
872
*/
873
- function runLogin ( entity ) {
873
+ async function runLogin ( entity ) {
874
874
const action = entity === 'Youtube' ? 'block-ctl-yt' : 'block-ctl-fb'
875
- unblockClickToLoadContent ( { entity, action, isLogin : true } )
875
+ await unblockClickToLoadContent ( { entity, action, isLogin : true } )
876
876
// Communicate with surrogate to run login
877
877
originalWindowDispatchEvent (
878
878
createCustomEvent ( 'ddg-ctp-run-login' , {
@@ -1782,13 +1782,6 @@ export default class ClickToLoad extends ContentFeature {
1782
1782
}
1783
1783
}
1784
1784
} )
1785
-
1786
- // Request the current state of Click to Load from the platform.
1787
- // Note: When the response is received, the response handler resolves
1788
- // the readyToDisplayPlaceholders Promise.
1789
- const clickToLoadState = await this . messaging . request ( 'getClickToLoadState' )
1790
- this . onClickToLoadState ( clickToLoadState )
1791
-
1792
1785
// Listen to message from Platform letting CTL know that we're ready to
1793
1786
// replace elements in the page
1794
1787
// eslint-disable-next-line promise/prefer-await-to-then
@@ -1797,10 +1790,14 @@ export default class ClickToLoad extends ContentFeature {
1797
1790
// TODO: Pass `message.options.ruleAction` through, that way only
1798
1791
// content corresponding to the entity for that ruleAction need to
1799
1792
// be replaced with a placeholder.
1800
- ( _ ) => replaceClickToLoadElements ( )
1793
+ ( ) => replaceClickToLoadElements ( )
1801
1794
)
1802
1795
1803
- await readyToDisplayPlaceholders
1796
+ // Request the current state of Click to Load from the platform.
1797
+ // Note: When the response is received, the response handler resolves
1798
+ // the readyToDisplayPlaceholders Promise.
1799
+ const clickToLoadState = await this . messaging . request ( 'getClickToLoadState' )
1800
+ this . onClickToLoadState ( clickToLoadState )
1804
1801
1805
1802
// Then wait for the page to finish loading, and resolve the
1806
1803
// afterPageLoad Promise.
0 commit comments