Fix race conditrion preventing window from opening (#6680)

Signed-off-by: Sebastian Malton <sebastian@malton.name>

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and Jim Ehrismann committed 2022-12-06 10:15:50 -05:00
1 parent 39a3f831a3
commit 86c94bfe36
1 file changed
+12 -3
@@ -44,6 +44,11 @@ export interface LensWindowConfiguration {
windowFrameUtilitiesAreShown: boolean;
centered: boolean;
titleBarStyle?: ElectronWindowTitleBarStyle;
/**
* This function is called before the ContentSource is used and then awaited after
* the open call resolves
*/
beforeOpen?: () => Promise<void>;
onFocus?: () => void;
onBlur?: () => void;
@@ -93,8 +98,12 @@ const createLensWindowInjectable = getInjectable({
},
});
const { file: filePathForContent, url: urlForContent } =
configuration.getContentSource();
const {
file: filePathForContent,
url: urlForContent,
} = configuration.getContentSource();
const beforeOpen = configuration.beforeOpen?.();
if (filePathForContent) {
await browserWindow.loadFile(filePathForContent);
@@ -102,7 +111,7 @@ const createLensWindowInjectable = getInjectable({
await browserWindow.loadUrl(urlForContent);
}
await configuration.beforeOpen?.();
await beforeOpen;
}
showWindow();