mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-15 11:06:21 +02:00
fix timeout value as onload was firing late on prod
This commit is contained in:
@ -21,7 +21,7 @@ const minCodeWrapSize = 33;
|
|||||||
/* global htmlCodeEl
|
/* global htmlCodeEl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const PREVIEW_FRAME_HOST = window.DEBUG
|
const PREVIEW_FRAME_HOST = window.location.href.includes('localhost')
|
||||||
? 'http://localhost:7888'
|
? 'http://localhost:7888'
|
||||||
: `https://wbmakr.com`;
|
: `https://wbmakr.com`;
|
||||||
|
|
||||||
@ -174,10 +174,16 @@ export default class ContentWrap extends Component {
|
|||||||
Promise.race([
|
Promise.race([
|
||||||
// Just in case onload promise doesn't resolves
|
// Just in case onload promise doesn't resolves
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
setTimeout(resolve, 400);
|
setTimeout(() => {
|
||||||
|
log('resolved with timeout');
|
||||||
|
resolve();
|
||||||
|
}, 1000);
|
||||||
}),
|
}),
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
this.frame.onload = resolve;
|
this.frame.onload = () => {
|
||||||
|
log('resolved with onload');
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
})
|
})
|
||||||
]).then(fn);
|
]).then(fn);
|
||||||
// Setting to blank string cause frame to reload
|
// Setting to blank string cause frame to reload
|
||||||
@ -200,6 +206,7 @@ export default class ContentWrap extends Component {
|
|||||||
this.frame.contentDocument.write(contents);
|
this.frame.contentDocument.write(contents);
|
||||||
this.frame.contentDocument.close();
|
this.frame.contentDocument.close();
|
||||||
} else {
|
} else {
|
||||||
|
console.log('sending PM');
|
||||||
this.frame.contentWindow.postMessage({ contents }, '*');
|
this.frame.contentWindow.postMessage({ contents }, '*');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user