1
0
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:
Iku-turso 2022-05-23 13:35:25 +03:00
parent d677a1bf81
commit 4b14ec10fa
9 changed files with 41 additions and 41 deletions

View File

@ -6,8 +6,8 @@ import type { DiContainer } 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 { 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 { sendToAgnosticChannelInjectionToken } from "./send-to-agnostic-channel-injection-token";
import type { SendToChannel } from "./send-to-channel-injection-token";
import { sendToChannelInjectionToken } from "./send-to-channel-injection-token";
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
import { channelListenerInjectionToken } from "./channel-listener-injection-token";
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 testListenerInWindowMock: jest.Mock;
let mainDi: DiContainer;
let sendToAgnosticChannel: SendToAgnosticChannel;
let sendToChannel: SendToChannel;
beforeEach(async () => {
const applicationBuilder = getApplicationBuilder();
@ -51,8 +51,8 @@ describe("channel", () => {
testChannel = mainDi.inject(testChannelInjectable);
sendToAgnosticChannel = mainDi.inject(
sendToAgnosticChannelInjectionToken,
sendToChannel = mainDi.inject(
sendToChannelInjectionToken,
);
await applicationBuilder.render();
@ -72,7 +72,7 @@ describe("channel", () => {
});
it("when sending message, triggers listener in window", () => {
sendToAgnosticChannel(testChannel, "some-message");
sendToChannel(testChannel, "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", () => {
someWindowFake.close();
sendToAgnosticChannel(testChannel, "some-message");
sendToChannel(testChannel, "some-message");
expect(testListenerInWindowMock).not.toHaveBeenCalled();
});
@ -93,7 +93,7 @@ describe("channel", () => {
await someWindowFake.show();
await someOtherWindowFake.show();
sendToAgnosticChannel(testChannel, "some-message");
sendToChannel(testChannel, "some-message");
expect(testListenerInWindowMock.mock.calls).toEqual([
["some-message"],
@ -107,7 +107,7 @@ describe("channel", () => {
let testListenerInMainMock: jest.Mock;
let rendererDi: DiContainer;
let mainDi: DiContainer;
let sendToAgnosticChannel: SendToAgnosticChannel;
let sendToChannel: SendToChannel;
beforeEach(async () => {
const applicationBuilder = getApplicationBuilder();
@ -137,15 +137,15 @@ describe("channel", () => {
testChannel = rendererDi.inject(testChannelInjectable);
sendToAgnosticChannel = rendererDi.inject(
sendToAgnosticChannelInjectionToken,
sendToChannel = rendererDi.inject(
sendToChannelInjectionToken,
);
await applicationBuilder.render();
});
it("when sending message, triggers listener in main", () => {
sendToAgnosticChannel(testChannel, "some-message");
sendToChannel(testChannel, "some-message");
expect(testListenerInMainMock).toHaveBeenCalledWith("some-message");
});

View File

@ -5,12 +5,12 @@
import { getInjectionToken } from "@ogre-tools/injectable";
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,
message?: TChannel["_messageTemplate"]
) => void;
export const sendToAgnosticChannelInjectionToken =
getInjectionToken<SendToAgnosticChannel>({
id: "send-to-agnostic-channel",
export const sendToChannelInjectionToken =
getInjectionToken<SendToChannel>({
id: "send-to-channel",
});

View File

@ -5,7 +5,7 @@
import { getInjectable } from "@ogre-tools/injectable";
import { computed } from "mobx";
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 type { SyncBox } from "./sync-box-injection-token";
@ -14,7 +14,7 @@ const createSyncBoxInjectable = getInjectable({
instantiate: (di) => {
const syncBoxChannel = di.inject(syncBoxChannelInjectable);
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
const sendToChannel = di.inject(sendToChannelInjectionToken);
const getSyncBoxState = (id: string) => di.inject(syncBoxStateInjectable, id);
return <TData>(id: string): SyncBox<TData> => {
@ -28,7 +28,7 @@ const createSyncBoxInjectable = getInjectable({
set: (value) => {
state.set(value);
sendToAgnosticChannel(syncBoxChannel, { id, value });
sendToChannel(syncBoxChannel, { id, value });
},
};
};

View File

@ -4,18 +4,18 @@
*/
import { getInjectable } from "@ogre-tools/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";
const broadcastChangeInUpdatingStatusInjectable = getInjectable({
id: "broadcast-change-in-updating-status",
instantiate: (di) => {
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
const sendToChannel = di.inject(sendToChannelInjectionToken);
const applicationUpdateStatusChannel = di.inject(applicationUpdateStatusChannelInjectable);
return (data: ApplicationUpdateStatusChannelMessage) => {
sendToAgnosticChannel(applicationUpdateStatusChannel, data);
sendToChannel(applicationUpdateStatusChannel, data);
};
},
});

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
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 askBooleanPromiseInjectable from "./ask-boolean-promise.injectable";
@ -21,7 +21,7 @@ const askBooleanInjectable = getInjectable({
id: "ask-boolean",
instantiate: (di): AskBoolean => {
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
const sendToChannel = di.inject(sendToChannelInjectionToken);
const askBooleanChannel = di.inject(askBooleanQuestionChannelInjectable);
return async ({ id, title, question }) => {
@ -29,7 +29,7 @@ const askBooleanInjectable = getInjectable({
returnValuePromise.clear();
await sendToAgnosticChannel(askBooleanChannel, { id, title, question });
await sendToChannel(askBooleanChannel, { id, title, question });
return await returnValuePromise.promise;
};

View File

@ -6,10 +6,10 @@ import { lensWindowInjectionToken } from "../start-main-application/lens-window/
import { pipeline } from "@ogre-tools/fp";
import { getInjectable } from "@ogre-tools/injectable";
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({
id: "send-to-agnostic-channel-main",
const sendToChannelInjectable = getInjectable({
id: "send-to-channel",
instantiate: (di) => {
const getAllLensWindows = () => di.injectMany(lensWindowInjectionToken);
@ -26,7 +26,7 @@ const sendToAgnosticChannelInjectable = getInjectable({
};
},
injectionToken: sendToAgnosticChannelInjectionToken,
injectionToken: sendToChannelInjectionToken,
});
export default sendToAgnosticChannelInjectable;
export default sendToChannelInjectable;

View File

@ -9,7 +9,7 @@ import askBooleanQuestionChannelInjectable from "../../common/ask-boolean/ask-bo
import showInfoNotificationInjectable from "../components/notifications/show-info-notification.injectable";
import { Button } from "../components/button";
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 notificationsStoreInjectable from "../components/notifications/notifications-store.injectable";
@ -19,12 +19,12 @@ const askBooleanQuestionChannelListenerInjectable = getInjectable({
instantiate: (di) => {
const questionChannel = di.inject(askBooleanQuestionChannelInjectable);
const showInfoNotification = di.inject(showInfoNotificationInjectable);
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
const sendToChannel = di.inject(sendToChannelInjectionToken);
const answerChannel = di.inject(askBooleanAnswerChannelInjectable);
const notificationsStore = di.inject(notificationsStoreInjectable);
const sendAnswerFor = (id: string) => (value: boolean) => {
sendToAgnosticChannel(answerChannel, { id, value });
sendToChannel(answerChannel, { id, value });
};
const closeNotification = (notificationId: string) => {

View File

@ -3,11 +3,11 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
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";
const sendToAgnosticChannelInjectable = getInjectable({
id: "send-to-agnostic-channel-main",
const sendToChannelInjectable = getInjectable({
id: "send-to-channel",
instantiate: (di) => {
const sendToMain = di.inject(sendToMainInjectable);
@ -17,7 +17,7 @@ const sendToAgnosticChannelInjectable = getInjectable({
};
},
injectionToken: sendToAgnosticChannelInjectionToken,
injectionToken: sendToChannelInjectionToken,
});
export default sendToAgnosticChannelInjectable;
export default sendToChannelInjectable;

View File

@ -3,18 +3,18 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
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";
const notifyThatRootFrameIsRenderedInjectable = getInjectable({
id: "notify-that-root-frame-is-rendered",
instantiate: (di) => {
const sendToAgnosticChannel = di.inject(sendToAgnosticChannelInjectionToken);
const sendToChannel = di.inject(sendToChannelInjectionToken);
const rootFrameRenderedChannel = di.inject(rootFrameRenderedChannelInjectable);
return () => {
sendToAgnosticChannel(rootFrameRenderedChannel);
sendToChannel(rootFrameRenderedChannel);
};
},
});