1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

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 2022-12-01 06:22:18 -08:00 committed by GitHub
parent 693f6ea9a5
commit 4cb1946110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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();