ui: scratchpad: fix load race

This commit is contained in:
undefined committed 2022-09-29 16:09:58 +08:00
1 parent 265b14236a
commit 39e9b4a9cc
2 files changed
+7 -1

No files matched your search

@@ -28,8 +28,13 @@ const loaders = {
},
};
let loadPromise = Promise.resolve();
export async function load(features = ['markdown']) {
let s = Date.now();
await loadPromise;
let resolve;
loadPromise = new Promise((r) => { resolve = r; });
if (!loaded) {
await loaders.i18n();
console.log('Loading monaco editor');
@@ -60,6 +65,7 @@ export async function load(features = ['markdown']) {
}
}
await res.loadThemePromise;
resolve();
return { monaco: res.default, registerAction: res.registerAction };
}