提交 d6bae1e5 编写于 作者: I Ivan 提交者: Fatih Acet

Ensure that WebView is fully loaded before sending message

上级 4fb448a0
......@@ -50,6 +50,10 @@ export default {
note.markdownRenderedOnServer = true;
}
});
window.vsCodeApi.postMessage({
command: 'appReady',
});
},
}
</script>
......
......@@ -64,10 +64,20 @@ const createPanel = issuable => {
});
};
async function handleCreate(panel, issuable) {
const discussions = await gitLabService.fetchDiscussions(issuable);
function sendIssuableAndDiscussions(panel, issuable, discussions, appIsReady) {
if (!discussions || !appIsReady) return;
panel.webview.postMessage({ type: 'issuableFetch', issuable, discussions });
}
async function handleCreate(panel, issuable) {
let discussions = false;
let appIsReady = false;
panel.webview.onDidReceiveMessage(async message => {
if (message.command === 'appReady') {
appIsReady = true;
sendIssuableAndDiscussions(panel, issuable, discussions, appIsReady);
}
if (message.command === 'renderMarkdown') {
let rendered = await gitLabService.renderMarkdown(message.markdown);
rendered = (rendered || '')
......@@ -97,6 +107,9 @@ async function handleCreate(panel, issuable) {
}
}
});
discussions = await gitLabService.fetchDiscussions(issuable);
sendIssuableAndDiscussions(panel, issuable, discussions, appIsReady);
}
async function create(issuable) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册