mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Convert shell authentication IPC to injectable RequestChannel
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
78ead4f2b9
commit
ea8c262d3c
20 files changed
+54
-110
No files matched your search
@@ -9,7 +9,6 @@ import type { SendToViewArgs } from "../../main/start-main-application/lens-wind
|
||||
import enlistMessageChannelListenerInjectableInRenderer from "../../renderer/utils/channel/channel-listeners/enlist-message-channel-listener.injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import assert from "assert";
|
||||
import { tentativeParseJson } from "../../common/utils/tentative-parse-json";
|
||||
|
||||
export const overrideMessagingFromMainToWindow = (mainDi: DiContainer) => {
|
||||
const messageChannelListenerFakesForRenderer = new Map<
|
||||
@@ -48,9 +47,7 @@ export const overrideMessagingFromMainToWindow = (mainDi: DiContainer) => {
|
||||
);
|
||||
}
|
||||
|
||||
const message = tentativeParseJson(data[0]);
|
||||
|
||||
listeners.forEach((listener) => listener.handler(message));
|
||||
listeners.forEach((listener) => listener.handler(data[0]));
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -44,11 +44,12 @@ export const overrideRequestingFromWindowToMain = (mainDi: DiContainer) => {
|
||||
requestFromChannelInjectable,
|
||||
|
||||
() => async (channel, ...[request]) => {
|
||||
const requestListener = requestChannelListenerFakesForMain.get(channel.id);
|
||||
const { id } = channel as unknown as RequestChannel<any, any>;
|
||||
const requestListener = requestChannelListenerFakesForMain.get(id);
|
||||
|
||||
if (!requestListener) {
|
||||
throw new Error(
|
||||
`Tried to get value from channel "${channel.id}", but no listeners were registered`,
|
||||
`Tried to get value from channel "${id}", but no listeners were registered`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user