1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-04-21 19:21:55 +02:00

fix timeout value as onload was firing late on prod

This commit is contained in:
Kushagra Gour 2024-05-08 16:58:31 +05:30
parent 636d2de5dc
commit c07c73963e

View File

@ -21,7 +21,7 @@ const minCodeWrapSize = 33;
/* global htmlCodeEl
*/
const PREVIEW_FRAME_HOST = window.DEBUG
const PREVIEW_FRAME_HOST = window.location.href.includes('localhost')
? 'http://localhost:7888'
: `https://wbmakr.com`;
@ -174,10 +174,16 @@ export default class ContentWrap extends Component {
Promise.race([
// Just in case onload promise doesn't resolves
new Promise(resolve => {
setTimeout(resolve, 400);
setTimeout(() => {
log('resolved with timeout');
resolve();
}, 1000);
}),
new Promise(resolve => {
this.frame.onload = resolve;
this.frame.onload = () => {
log('resolved with onload');
resolve();
};
})
]).then(fn);
// 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.close();
} else {
console.log('sending PM');
this.frame.contentWindow.postMessage({ contents }, '*');
}
};