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([]);
|
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", () => {
|
describe("when opening of splash window resolves", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await resolveOpeningOfWindow("splash");
|
await resolveOpeningOfWindow("splash");
|
||||||
@ -101,7 +113,7 @@ describe("opening application window using tray", () => {
|
|||||||
expectWindowsToBeOpen(["only-application-window"]);
|
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(() => {
|
beforeEach(() => {
|
||||||
createElectronWindowMock.mockClear();
|
createElectronWindowMock.mockClear();
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,8 @@ const createLensWindowInjectable = getInjectable({
|
|||||||
configuration,
|
configuration,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
let windowIsOpening = false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: configuration.id,
|
id: configuration.id,
|
||||||
|
|
||||||
@ -53,12 +55,18 @@ const createLensWindowInjectable = getInjectable({
|
|||||||
return !!browserWindow;
|
return !!browserWindow;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get opening() {
|
||||||
|
return windowIsOpening;
|
||||||
|
},
|
||||||
|
|
||||||
show: async () => {
|
show: async () => {
|
||||||
if (!browserWindow) {
|
if (!browserWindow) {
|
||||||
|
windowIsOpening = true;
|
||||||
browserWindow = await createElectronWindow();
|
browserWindow = await createElectronWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
browserWindow.show();
|
browserWindow.show();
|
||||||
|
windowIsOpening = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
close: () => {
|
close: () => {
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export interface LensWindow {
|
|||||||
close: () => void;
|
close: () => void;
|
||||||
send: (args: SendToViewArgs) => void;
|
send: (args: SendToViewArgs) => void;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
opening: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const lensWindowInjectionToken = getInjectionToken<LensWindow>({
|
export const lensWindowInjectionToken = getInjectionToken<LensWindow>({
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import splashWindowInjectable from "./splash-window/splash-window.injectable";
|
import splashWindowInjectable from "./splash-window/splash-window.injectable";
|
||||||
import applicationWindowInjectable from "./application-window/application-window.injectable";
|
import applicationWindowInjectable from "./application-window/application-window.injectable";
|
||||||
|
import { identity, some } from "lodash/fp";
|
||||||
|
const someIsTruthy = some(identity);
|
||||||
|
|
||||||
const showApplicationWindowInjectable = getInjectable({
|
const showApplicationWindowInjectable = getInjectable({
|
||||||
id: "show-application-window",
|
id: "show-application-window",
|
||||||
@ -12,12 +14,17 @@ const showApplicationWindowInjectable = getInjectable({
|
|||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const applicationWindow = di.inject(applicationWindowInjectable);
|
const applicationWindow = di.inject(applicationWindowInjectable);
|
||||||
|
|
||||||
const splashWindow = di.inject(
|
const splashWindow = di.inject(splashWindowInjectable);
|
||||||
splashWindowInjectable,
|
|
||||||
);
|
|
||||||
|
|
||||||
return async () => {
|
return async () => {
|
||||||
if (applicationWindow.visible || splashWindow.visible) {
|
const windowIsAlreadyBeingShown = someIsTruthy([
|
||||||
|
applicationWindow.visible,
|
||||||
|
applicationWindow.opening,
|
||||||
|
splashWindow.visible,
|
||||||
|
splashWindow.opening,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (windowIsAlreadyBeingShown) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user