mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Simplify naming
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
d677a1bf81
commit
4b14ec10fa
@ -6,8 +6,8 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { LensWindow } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
import type { LensWindow } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
||||||
import { lensWindowInjectionToken } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
import { lensWindowInjectionToken } from "../../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
||||||
import type { SendToAgnosticChannel } from "./send-to-agnostic-channel-injection-token";
|
import type { SendToChannel } from "./send-to-channel-injection-token";
|
||||||
import { sendToAgnosticChannelInjectionToken } from "./send-to-agnostic-channel-injection-token";
|
import { sendToChannelInjectionToken } from "./send-to-channel-injection-token";
|
||||||
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
|
||||||
import { channelListenerInjectionToken } from "./channel-listener-injection-token";
|
import { channelListenerInjectionToken } from "./channel-listener-injection-token";
|
||||||
import createLensWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
import createLensWindowInjectable from "../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
|
||||||
@ -21,7 +21,7 @@ describe("channel", () => {
|
|||||||
let testChannel: TestChannel;
|
let testChannel: TestChannel;
|
||||||
let testListenerInWindowMock: jest.Mock;
|
let testListenerInWindowMock: jest.Mock;
|
||||||
let mainDi: DiContainer;
|
let mainDi: DiContainer;
|
||||||
let sendToAgnosticChannel: SendToAgnosticChannel;
|
let sendToChannel: SendToChannel;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const applicationBuilder = getApplicationBuilder();
|
const applicationBuilder = getApplicationBuilder();
|
||||||
@ -51,8 +51,8 @@ describe("channel", () => {
|
|||||||
|
|
||||||
testChannel = mainDi.inject(testChannelInjectable);
|
testChannel = mainDi.inject(testChannelInjectable);
|
||||||
|
|
||||||
sendToAgnosticChannel = mainDi.inject(
|
sendToChannel = mainDi.inject(
|
||||||
sendToAgnosticChannelInjectionToken,
|
sendToChannelInjectionToken,
|
||||||
);
|
);
|
||||||
|
|
||||||
await applicationBuilder.render();
|
await applicationBuilder.render();
|
||||||
@ -72,7 +72,7 @@ describe("channel", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("when sending message, triggers listener in window", () => {
|
it("when sending message, triggers listener in window", () => {
|
||||||
sendToAgnosticChannel(testChannel, "some-message");
|
sendToChannel(testChannel, "some-message");
|
||||||
|
|
||||||
expect(testListenerInWindowMock).toHaveBeenCalledWith("some-message");
|
expect(testListenerInWindowMock).toHaveBeenCalledWith("some-message");
|
||||||
});
|
});
|
||||||
@ -80,7 +80,7 @@ describe("channel", () => {
|
|||||||
it("given window is hidden, when sending message, does not trigger listener in window", () => {
|
it("given window is hidden, when sending message, does not trigger listener in window", () => {
|
||||||
someWindowFake.close();
|
someWindowFake.close();
|
||||||
|
|
||||||
sendToAgnosticChannel(testChannel, "some-message");
|
sendToChannel(testChannel, "some-message");
|
||||||
|
|
||||||
expect(testListenerInWindowMock).not.toHaveBeenCalled();
|
expect(testListenerInWindowMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -93,7 +93,7 @@ describe("channel", () => {
|
|||||||
await someWindowFake.show();
|
await someWindowFake.show();
|
||||||
await someOtherWindowFake.show();
|
await someOtherWindowFake.show();
|
||||||
|
|
||||||
sendToAgnosticChannel(testChannel, "some-message");
|
sendToChannel(testChannel, "some-message");
|
||||||
|
|
||||||
expect(testListenerInWindowMock.mock.calls).toEqual([
|
expect(testListenerInWindowMock.mock.calls).toEqual([
|
||||||
["some-message"],
|
["some-message"],
|
||||||
@ -107,7 +107,7 @@ describe("channel", () => {
|
|||||||
let testListenerInMainMock: jest.Mock;
|
let testListenerInMainMock: jest.Mock;
|
||||||
let rendererDi: DiContainer;
|
let rendererDi: DiContainer;
|
||||||
let mainDi: DiContainer;
|
let mainDi: DiContainer;
|
||||||
let sendToAgnosticChannel: SendToAgnosticChannel;
|
let sendToChannel: SendToChannel;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const applicationBuilder = getApplicationBuilder();
|
const applicationBuilder = getApplicationBuilder();
|
||||||
@ -137,15 +137,15 @@ describe("channel", () => {
|
|||||||
|
|
||||||
testChannel = rendererDi.inject(testChannelInjectable);
|
testChannel = rendererDi.inject(testChannelInjectable);
|
||||||
|
|
||||||
sendToAgnosticChannel = rendererDi.inject(
|
sendToChannel = rendererDi.inject(
|
||||||
sendToAgnosticChannelInjectionToken,
|
sendToChannelInjectionToken,
|
||||||
);
|
);
|
||||||
|
|
||||||
await applicationBuilder.render();
|
await applicationBuilder.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when sending message, triggers listener in main", () => {
|
it("when sending message, triggers listener in main", () => {
|
||||||
sendToAgnosticChannel(testChannel, "some-message");
|
sendToChannel(testChannel, "some-message");
|
||||||
|
|
||||||
expect(testListenerInMainMock).toHaveBeenCalledWith("some-message");
|
expect(testListenerInMainMock).toHaveBeenCalledWith("some-message");
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,12 +5,12 @@
|
|||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
import type { Channel } from "./channel-injection-token";
|
import type { Channel } from "./channel-injection-token";
|
||||||
|
|
||||||
export type SendToAgnosticChannel = <TChannel extends Channel<unknown, unknown>>(
|
export type SendToChannel = <TChannel extends Channel<unknown, unknown>>(
|
||||||
channel: TChannel,
|
channel: TChannel,
|
||||||
message?: TChannel["_messageTemplate"]
|
message?: TChannel["_messageTemplate"]
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
export const sendToAgnosticChannelInjectionToken =
|
export const sendToChannelInjectionToken =
|
||||||
getInjectionToken<SendToAgnosticChannel>({
|
getInjectionToken<SendToChannel>({
|
||||||
id: "send-to-agnostic-channel",
|
id: "send-to-channel",
|
||||||
});
|
});
|
||||||
@ -5,7 +5,7 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
import syncBoxChannelInjectable from "./sync-box-channel.injectable";
|
import syncBoxChannelInjectable from "./sync-box-channel.injectable";
|
||||||
import { sendToAgnosticChannelInjectionToken } from "../channel/send-to-agnostic-channel-injection-token";
|
import { sendToChannelInjectionToken } from "../channel/send-to-channel-injection-token";
|
||||||
import syncBoxStateInjectable from "./sync-box-state.injectable";
|
import syncBoxStateInjectable from "./sync-box-state.injectable";
|
||||||
import type { SyncBox } from "./sync-box-injection-token";
|
import type { SyncBox } from "./sync-box-injection-token";
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ const createSyncBoxInjectable = getInjectable({
|
|||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const syncBoxChannel = di.inject(syncBoxChannelInjectable);
|
const syncBoxChannel = di.inject(syncBoxChannelInjectable);
|
||||||
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
|
const sendToChannel = di.inject(sendToChannelInjectionToken);
|
||||||
const getSyncBoxState = (id: string) => di.inject(syncBoxStateInjectable, id);
|
const getSyncBoxState = (id: string) => di.inject(syncBoxStateInjectable, id);
|
||||||
|
|
||||||
return <TData>(id: string): SyncBox<TData> => {
|
return <TData>(id: string): SyncBox<TData> => {
|
||||||
@ -28,7 +28,7 @@ const createSyncBoxInjectable = getInjectable({
|
|||||||
set: (value) => {
|
set: (value) => {
|
||||||
state.set(value);
|
state.set(value);
|
||||||
|
|
||||||
sendToAgnosticChannel(syncBoxChannel, { id, value });
|
sendToChannel(syncBoxChannel, { id, value });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,18 +4,18 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { ApplicationUpdateStatusChannelMessage } from "../../../common/application-update/application-update-status-channel.injectable";
|
import type { ApplicationUpdateStatusChannelMessage } from "../../../common/application-update/application-update-status-channel.injectable";
|
||||||
import { sendToAgnosticChannelInjectionToken } from "../../../common/channel/send-to-agnostic-channel-injection-token";
|
import { sendToChannelInjectionToken } from "../../../common/channel/send-to-channel-injection-token";
|
||||||
import applicationUpdateStatusChannelInjectable from "../../../common/application-update/application-update-status-channel.injectable";
|
import applicationUpdateStatusChannelInjectable from "../../../common/application-update/application-update-status-channel.injectable";
|
||||||
|
|
||||||
const broadcastChangeInUpdatingStatusInjectable = getInjectable({
|
const broadcastChangeInUpdatingStatusInjectable = getInjectable({
|
||||||
id: "broadcast-change-in-updating-status",
|
id: "broadcast-change-in-updating-status",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
|
const sendToChannel = di.inject(sendToChannelInjectionToken);
|
||||||
const applicationUpdateStatusChannel = di.inject(applicationUpdateStatusChannelInjectable);
|
const applicationUpdateStatusChannel = di.inject(applicationUpdateStatusChannelInjectable);
|
||||||
|
|
||||||
return (data: ApplicationUpdateStatusChannelMessage) => {
|
return (data: ApplicationUpdateStatusChannelMessage) => {
|
||||||
sendToAgnosticChannel(applicationUpdateStatusChannel, data);
|
sendToChannel(applicationUpdateStatusChannel, data);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { sendToAgnosticChannelInjectionToken } from "../../common/channel/send-to-agnostic-channel-injection-token";
|
import { sendToChannelInjectionToken } from "../../common/channel/send-to-channel-injection-token";
|
||||||
import askBooleanQuestionChannelInjectable from "../../common/ask-boolean/ask-boolean-question-channel.injectable";
|
import askBooleanQuestionChannelInjectable from "../../common/ask-boolean/ask-boolean-question-channel.injectable";
|
||||||
import askBooleanPromiseInjectable from "./ask-boolean-promise.injectable";
|
import askBooleanPromiseInjectable from "./ask-boolean-promise.injectable";
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ const askBooleanInjectable = getInjectable({
|
|||||||
id: "ask-boolean",
|
id: "ask-boolean",
|
||||||
|
|
||||||
instantiate: (di): AskBoolean => {
|
instantiate: (di): AskBoolean => {
|
||||||
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
|
const sendToChannel = di.inject(sendToChannelInjectionToken);
|
||||||
const askBooleanChannel = di.inject(askBooleanQuestionChannelInjectable);
|
const askBooleanChannel = di.inject(askBooleanQuestionChannelInjectable);
|
||||||
|
|
||||||
return async ({ id, title, question }) => {
|
return async ({ id, title, question }) => {
|
||||||
@ -29,7 +29,7 @@ const askBooleanInjectable = getInjectable({
|
|||||||
|
|
||||||
returnValuePromise.clear();
|
returnValuePromise.clear();
|
||||||
|
|
||||||
await sendToAgnosticChannel(askBooleanChannel, { id, title, question });
|
await sendToChannel(askBooleanChannel, { id, title, question });
|
||||||
|
|
||||||
return await returnValuePromise.promise;
|
return await returnValuePromise.promise;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,10 +6,10 @@ import { lensWindowInjectionToken } from "../start-main-application/lens-window/
|
|||||||
import { pipeline } from "@ogre-tools/fp";
|
import { pipeline } from "@ogre-tools/fp";
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { filter } from "lodash/fp";
|
import { filter } from "lodash/fp";
|
||||||
import { sendToAgnosticChannelInjectionToken } from "../../common/channel/send-to-agnostic-channel-injection-token";
|
import { sendToChannelInjectionToken } from "../../common/channel/send-to-channel-injection-token";
|
||||||
|
|
||||||
const sendToAgnosticChannelInjectable = getInjectable({
|
const sendToChannelInjectable = getInjectable({
|
||||||
id: "send-to-agnostic-channel-main",
|
id: "send-to-channel",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const getAllLensWindows = () => di.injectMany(lensWindowInjectionToken);
|
const getAllLensWindows = () => di.injectMany(lensWindowInjectionToken);
|
||||||
@ -26,7 +26,7 @@ const sendToAgnosticChannelInjectable = getInjectable({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
injectionToken: sendToAgnosticChannelInjectionToken,
|
injectionToken: sendToChannelInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default sendToAgnosticChannelInjectable;
|
export default sendToChannelInjectable;
|
||||||
@ -9,7 +9,7 @@ import askBooleanQuestionChannelInjectable from "../../common/ask-boolean/ask-bo
|
|||||||
import showInfoNotificationInjectable from "../components/notifications/show-info-notification.injectable";
|
import showInfoNotificationInjectable from "../components/notifications/show-info-notification.injectable";
|
||||||
import { Button } from "../components/button";
|
import { Button } from "../components/button";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { sendToAgnosticChannelInjectionToken } from "../../common/channel/send-to-agnostic-channel-injection-token";
|
import { sendToChannelInjectionToken } from "../../common/channel/send-to-channel-injection-token";
|
||||||
import askBooleanAnswerChannelInjectable from "../../common/ask-boolean/ask-boolean-answer-channel.injectable";
|
import askBooleanAnswerChannelInjectable from "../../common/ask-boolean/ask-boolean-answer-channel.injectable";
|
||||||
import notificationsStoreInjectable from "../components/notifications/notifications-store.injectable";
|
import notificationsStoreInjectable from "../components/notifications/notifications-store.injectable";
|
||||||
|
|
||||||
@ -19,12 +19,12 @@ const askBooleanQuestionChannelListenerInjectable = getInjectable({
|
|||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const questionChannel = di.inject(askBooleanQuestionChannelInjectable);
|
const questionChannel = di.inject(askBooleanQuestionChannelInjectable);
|
||||||
const showInfoNotification = di.inject(showInfoNotificationInjectable);
|
const showInfoNotification = di.inject(showInfoNotificationInjectable);
|
||||||
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
|
const sendToChannel = di.inject(sendToChannelInjectionToken);
|
||||||
const answerChannel = di.inject(askBooleanAnswerChannelInjectable);
|
const answerChannel = di.inject(askBooleanAnswerChannelInjectable);
|
||||||
const notificationsStore = di.inject(notificationsStoreInjectable);
|
const notificationsStore = di.inject(notificationsStoreInjectable);
|
||||||
|
|
||||||
const sendAnswerFor = (id: string) => (value: boolean) => {
|
const sendAnswerFor = (id: string) => (value: boolean) => {
|
||||||
sendToAgnosticChannel(answerChannel, { id, value });
|
sendToChannel(answerChannel, { id, value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeNotification = (notificationId: string) => {
|
const closeNotification = (notificationId: string) => {
|
||||||
|
|||||||
@ -3,11 +3,11 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { sendToAgnosticChannelInjectionToken } from "../../common/channel/send-to-agnostic-channel-injection-token";
|
import { sendToChannelInjectionToken } from "../../common/channel/send-to-channel-injection-token";
|
||||||
import sendToMainInjectable from "./send-to-main.injectable";
|
import sendToMainInjectable from "./send-to-main.injectable";
|
||||||
|
|
||||||
const sendToAgnosticChannelInjectable = getInjectable({
|
const sendToChannelInjectable = getInjectable({
|
||||||
id: "send-to-agnostic-channel-main",
|
id: "send-to-channel",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const sendToMain = di.inject(sendToMainInjectable);
|
const sendToMain = di.inject(sendToMainInjectable);
|
||||||
@ -17,7 +17,7 @@ const sendToAgnosticChannelInjectable = getInjectable({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
injectionToken: sendToAgnosticChannelInjectionToken,
|
injectionToken: sendToChannelInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default sendToAgnosticChannelInjectable;
|
export default sendToChannelInjectable;
|
||||||
@ -3,18 +3,18 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { sendToAgnosticChannelInjectionToken } from "../../../common/channel/send-to-agnostic-channel-injection-token";
|
import { sendToChannelInjectionToken } from "../../../common/channel/send-to-channel-injection-token";
|
||||||
import rootFrameRenderedChannelInjectable from "../../../common/root-frame-rendered-channel/root-frame-rendered-channel.injectable";
|
import rootFrameRenderedChannelInjectable from "../../../common/root-frame-rendered-channel/root-frame-rendered-channel.injectable";
|
||||||
|
|
||||||
const notifyThatRootFrameIsRenderedInjectable = getInjectable({
|
const notifyThatRootFrameIsRenderedInjectable = getInjectable({
|
||||||
id: "notify-that-root-frame-is-rendered",
|
id: "notify-that-root-frame-is-rendered",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
|
const sendToChannel = di.inject(sendToChannelInjectionToken);
|
||||||
const rootFrameRenderedChannel = di.inject(rootFrameRenderedChannelInjectable);
|
const rootFrameRenderedChannel = di.inject(rootFrameRenderedChannelInjectable);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
sendToAgnosticChannel(rootFrameRenderedChannel);
|
sendToChannel(rootFrameRenderedChannel);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user