Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions emain/emain-ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { callWithOriginalXdgCurrentDesktopAsync, unamePlatform } from "./emain-p
import { getWaveTabViewByWebContentsId } from "./emain-tabview";
import { handleCtrlShiftState } from "./emain-util";
import { getWaveVersion } from "./emain-wavesrv";
import { createNewWaveWindow, focusedWaveWindow, getWaveWindowByWebContentsId } from "./emain-window";
import { createNewWaveWindow, getWaveWindowByWebContentsId } from "./emain-window";
import { ElectronWshClient } from "./emain-wsh";

const electronApp = electron.app;
Expand Down Expand Up @@ -130,11 +130,16 @@ function getUrlInSession(session: Electron.Session, url: string): Promise<UrlInS
});
}

function saveImageFileWithNativeDialog(defaultFileName: string, mimeType: string, readStream: Readable) {
function saveImageFileWithNativeDialog(
sender: electron.WebContents,
defaultFileName: string,
mimeType: string,
readStream: Readable
) {
if (defaultFileName == null || defaultFileName == "") {
defaultFileName = "image";
}
const ww = focusedWaveWindow;
const ww = electron.BrowserWindow.fromWebContents(sender);
if (ww == null) {
return;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -213,7 +218,12 @@ export function initIpcHandlers() {
const resultP = getUrlInSession(event.sender.session, payload.src);
resultP
.then((result) => {
saveImageFileWithNativeDialog(result.fileName, result.mimeType, result.stream);
saveImageFileWithNativeDialog(
event.sender.hostWebContents,
result.fileName,
result.mimeType,
result.stream
);
})
.catch((e) => {
console.log("error getting image", e);
Expand Down Expand Up @@ -477,7 +487,7 @@ export function initIpcHandlers() {
});

electron.ipcMain.handle("save-text-file", async (event, fileName: string, content: string) => {
const ww = focusedWaveWindow;
const ww = electron.BrowserWindow.fromWebContents(event.sender);
if (ww == null) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions emain/emain-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class WaveBrowserWindow extends BaseWindow {
if (getGlobalIsRelaunching()) {
return;
}
focusedWaveWindow = this; // eslint-disable-line @typescript-eslint/no-this-alias
console.log("focus win", this.waveWindowId);
fireAndForget(() => ClientService.FocusWindow(this.waveWindowId));
setWasInFg(true);
Expand Down
Loading