From 4b14ec10fa4b0bb2af8f98b9565dc382ed1fb500 Mon Sep 17 00:00:00 2001 From: Iku-turso Date: Mon, 23 May 2022 13:35:25 +0300 Subject: [PATCH] Simplify naming Co-authored-by: Janne Savolainen Signed-off-by: Iku-turso --- src/common/channel/channel.test.ts | 24 +++++++++---------- ....ts => send-to-channel-injection-token.ts} | 8 +++---- .../sync-box/create-sync-box.injectable.ts | 6 ++--- ...st-change-in-updating-status.injectable.ts | 6 ++--- .../ask-boolean/ask-boolean.injectable.ts | 6 ++--- ...table.ts => send-to-channel.injectable.ts} | 10 ++++---- ...n-question-channel-listener.injectable.tsx | 6 ++--- ...table.ts => send-to-channel.injectable.ts} | 10 ++++---- ...-that-root-frame-is-rendered.injectable.ts | 6 ++--- 9 files changed, 41 insertions(+), 41 deletions(-) rename src/common/channel/{send-to-agnostic-channel-injection-token.ts => send-to-channel-injection-token.ts} (61%) rename src/main/channel/{send-to-agnostic-channel.injectable.ts => send-to-channel.injectable.ts} (72%) rename src/renderer/channel/{send-to-agnostic-channel.injectable.ts => send-to-channel.injectable.ts} (58%) diff --git a/src/common/channel/channel.test.ts b/src/common/channel/channel.test.ts index b71329e1be..102567dbb9 100644 --- a/src/common/channel/channel.test.ts +++ b/src/common/channel/channel.test.ts @@ -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"); }); diff --git a/src/common/channel/send-to-agnostic-channel-injection-token.ts b/src/common/channel/send-to-channel-injection-token.ts similarity index 61% rename from src/common/channel/send-to-agnostic-channel-injection-token.ts rename to src/common/channel/send-to-channel-injection-token.ts index a56e1fbb8b..33c9c38d73 100644 --- a/src/common/channel/send-to-agnostic-channel-injection-token.ts +++ b/src/common/channel/send-to-channel-injection-token.ts @@ -5,12 +5,12 @@ import { getInjectionToken } from "@ogre-tools/injectable"; import type { Channel } from "./channel-injection-token"; -export type SendToAgnosticChannel = >( +export type SendToChannel = >( channel: TChannel, message?: TChannel["_messageTemplate"] ) => void; -export const sendToAgnosticChannelInjectionToken = - getInjectionToken({ - id: "send-to-agnostic-channel", +export const sendToChannelInjectionToken = + getInjectionToken({ + id: "send-to-channel", }); diff --git a/src/common/sync-box/create-sync-box.injectable.ts b/src/common/sync-box/create-sync-box.injectable.ts index 82cf4b637a..bd92858969 100644 --- a/src/common/sync-box/create-sync-box.injectable.ts +++ b/src/common/sync-box/create-sync-box.injectable.ts @@ -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 (id: string): SyncBox => { @@ -28,7 +28,7 @@ const createSyncBoxInjectable = getInjectable({ set: (value) => { state.set(value); - sendToAgnosticChannel(syncBoxChannel, { id, value }); + sendToChannel(syncBoxChannel, { id, value }); }, }; }; diff --git a/src/main/application-update/check-for-updates/broadcast-change-in-updating-status.injectable.ts b/src/main/application-update/check-for-updates/broadcast-change-in-updating-status.injectable.ts index f6713d50e8..9d5566b83d 100644 --- a/src/main/application-update/check-for-updates/broadcast-change-in-updating-status.injectable.ts +++ b/src/main/application-update/check-for-updates/broadcast-change-in-updating-status.injectable.ts @@ -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); }; }, }); diff --git a/src/main/ask-boolean/ask-boolean.injectable.ts b/src/main/ask-boolean/ask-boolean.injectable.ts index 4f1f6b07fd..60cac6a5a4 100644 --- a/src/main/ask-boolean/ask-boolean.injectable.ts +++ b/src/main/ask-boolean/ask-boolean.injectable.ts @@ -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; }; diff --git a/src/main/channel/send-to-agnostic-channel.injectable.ts b/src/main/channel/send-to-channel.injectable.ts similarity index 72% rename from src/main/channel/send-to-agnostic-channel.injectable.ts rename to src/main/channel/send-to-channel.injectable.ts index 9758e5e308..0e5f6d87c5 100644 --- a/src/main/channel/send-to-agnostic-channel.injectable.ts +++ b/src/main/channel/send-to-channel.injectable.ts @@ -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; diff --git a/src/renderer/ask-boolean/ask-boolean-question-channel-listener.injectable.tsx b/src/renderer/ask-boolean/ask-boolean-question-channel-listener.injectable.tsx index a99e6398d9..0b84a87e6b 100644 --- a/src/renderer/ask-boolean/ask-boolean-question-channel-listener.injectable.tsx +++ b/src/renderer/ask-boolean/ask-boolean-question-channel-listener.injectable.tsx @@ -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) => { diff --git a/src/renderer/channel/send-to-agnostic-channel.injectable.ts b/src/renderer/channel/send-to-channel.injectable.ts similarity index 58% rename from src/renderer/channel/send-to-agnostic-channel.injectable.ts rename to src/renderer/channel/send-to-channel.injectable.ts index 9d2ed08fc2..54da7d4512 100644 --- a/src/renderer/channel/send-to-agnostic-channel.injectable.ts +++ b/src/renderer/channel/send-to-channel.injectable.ts @@ -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; diff --git a/src/renderer/frames/root-frame/notify-that-root-frame-is-rendered.injectable.ts b/src/renderer/frames/root-frame/notify-that-root-frame-is-rendered.injectable.ts index 9f37e769b7..ab36faf4a6 100644 --- a/src/renderer/frames/root-frame/notify-that-root-frame-is-rendered.injectable.ts +++ b/src/renderer/frames/root-frame/notify-that-root-frame-is-rendered.injectable.ts @@ -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); }; }, });