mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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>
This commit is contained in:
parent
37184455aa
commit
f91e88788b
@ -86,6 +86,18 @@ describe("opening application window using tray", () => {
|
||||
expectWindowsToBeOpen([]);
|
||||
});
|
||||
|
||||
describe("given opening of splash window has not finished yet, but another attempt to open the application is made", () => {
|
||||
beforeEach(() => {
|
||||
createElectronWindowMock.mockClear();
|
||||
|
||||
applicationBuilder.tray.click("open-app");
|
||||
});
|
||||
|
||||
it("does not open any new windows", () => {
|
||||
expect(createElectronWindowMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when opening of splash window resolves", () => {
|
||||
beforeEach(async () => {
|
||||
await resolveOpeningOfWindow("splash");
|
||||
@ -101,7 +113,7 @@ describe("opening application window using tray", () => {
|
||||
expectWindowsToBeOpen(["only-application-window"]);
|
||||
});
|
||||
|
||||
describe("given opening has not finished yet, but another attempt to open the application is made", () => {
|
||||
describe("given opening of application window has not finished yet, but another attempt to open the application is made", () => {
|
||||
beforeEach(() => {
|
||||
createElectronWindowMock.mockClear();
|
||||
|
||||
|
||||
@ -46,6 +46,8 @@ const createLensWindowInjectable = getInjectable({
|
||||
configuration,
|
||||
));
|
||||
|
||||
let windowIsOpening = false;
|
||||
|
||||
return {
|
||||
id: configuration.id,
|
||||
|
||||
@ -53,12 +55,18 @@ const createLensWindowInjectable = getInjectable({
|
||||
return !!browserWindow;
|
||||
},
|
||||
|
||||
get opening() {
|
||||
return windowIsOpening;
|
||||
},
|
||||
|
||||
show: async () => {
|
||||
if (!browserWindow) {
|
||||
windowIsOpening = true;
|
||||
browserWindow = await createElectronWindow();
|
||||
}
|
||||
|
||||
browserWindow.show();
|
||||
windowIsOpening = false;
|
||||
},
|
||||
|
||||
close: () => {
|
||||
|
||||
@ -17,6 +17,7 @@ export interface LensWindow {
|
||||
close: () => void;
|
||||
send: (args: SendToViewArgs) => void;
|
||||
visible: boolean;
|
||||
opening: boolean;
|
||||
}
|
||||
|
||||
export const lensWindowInjectionToken = getInjectionToken<LensWindow>({
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
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",
|
||||
@ -12,12 +14,17 @@ const showApplicationWindowInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const applicationWindow = di.inject(applicationWindowInjectable);
|
||||
|
||||
const splashWindow = di.inject(
|
||||
splashWindowInjectable,
|
||||
);
|
||||
const splashWindow = di.inject(splashWindowInjectable);
|
||||
|
||||
return async () => {
|
||||
if (applicationWindow.visible || splashWindow.visible) {
|
||||
const windowIsAlreadyBeingShown = someIsTruthy([
|
||||
applicationWindow.visible,
|
||||
applicationWindow.opening,
|
||||
splashWindow.visible,
|
||||
splashWindow.opening,
|
||||
]);
|
||||
|
||||
if (windowIsAlreadyBeingShown) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user