1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/start-main-application/lens-window/show-application-window.injectable.ts
Iku-turso 7b043afe42
Make sure bug about opening involuntary duplicate app windows is solved in all scenarios
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2022-06-15 08:40:18 +03:00

41 lines
1.1 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import splashWindowInjectable from "./splash-window/splash-window.injectable";
import applicationWindowInjectable from "./application-window/application-window.injectable";
import { identity, some } from "lodash/fp";
const someIsTruthy = some(identity);
const showApplicationWindowInjectable = getInjectable({
id: "show-application-window",
instantiate: (di) => {
const applicationWindow = di.inject(applicationWindowInjectable);
const splashWindow = di.inject(splashWindowInjectable);
return async () => {
const windowIsAlreadyBeingShown = someIsTruthy([
applicationWindow.visible,
applicationWindow.opening,
splashWindow.visible,
splashWindow.opening,
]);
if (windowIsAlreadyBeingShown) {
return;
}
await splashWindow.show();
await applicationWindow.show();
splashWindow.close();
};
},
});
export default showApplicationWindowInjectable;