Skip to content
Merged
15 changes: 5 additions & 10 deletions apps/desktop/src/ipc/methods/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DesktopPreviewConfigInputSchema,
DesktopPreviewNavigateInputSchema,
DesktopPreviewRecordingArtifactSchema,
DesktopPreviewRecordingSourceSchema,
DesktopPreviewRecordingSaveInputSchema,
DesktopPreviewRegisterWebviewInputSchema,
DesktopPreviewScreenshotArtifactSchema,
Expand Down Expand Up @@ -174,15 +173,11 @@ export const cancelPickElement = tabMethod(
"desktop.ipc.preview.cancelPickElement",
(manager, tabId) => manager.cancelPickElement(tabId),
);
export const startRecording = DesktopIpc.makeIpcMethod({
channel: IpcChannels.PREVIEW_RECORDING_START_CHANNEL,
payload: DesktopPreviewTabInputSchema,
result: DesktopPreviewRecordingSourceSchema,
handler: Effect.fn("desktop.ipc.preview.startRecording")(function* ({ tabId }) {
const manager = yield* PreviewManager.PreviewManager;
return yield* manager.startRecording(tabId);
}),
});
export const startRecording = tabMethod(
IpcChannels.PREVIEW_RECORDING_START_CHANNEL,
"desktop.ipc.preview.startRecording",
(manager, tabId) => manager.startRecording(tabId),
);
export const stopRecording = tabMethod(
IpcChannels.PREVIEW_RECORDING_STOP_CHANNEL,
"desktop.ipc.preview.stopRecording",
Expand Down
16 changes: 13 additions & 3 deletions apps/desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,19 @@ contextBridge.exposeInMainWorld("desktopBridge", {
};
},
onQuitShortcut: (listener) => {
const wrappedListener = (_event: Electron.IpcRendererEvent, state: unknown) => {
if (state !== "down" && state !== "up") return;
listener(state);
const wrappedListener = (_event: Electron.IpcRendererEvent, hint: unknown) => {
if (typeof hint !== "object" || hint === null || !("state" in hint)) return;
if (hint.state === "up") {
listener({ state: "up" });
return;
}
if (
hint.state === "down" &&
"mode" in hint &&
(hint.mode === "hold" || hint.mode === "double-click")
) {
listener({ state: "down", mode: hint.mode });
}
};

ipcRenderer.on(IpcChannels.QUIT_SHORTCUT_CHANNEL, wrappedListener);
Expand Down
Loading
Loading