Skip to content

Commit

Permalink
Resolved: Some pictures are lost when exporting chat #1812
Browse files Browse the repository at this point in the history
  • Loading branch information
KhushamBansal authored Jan 9, 2025
1 parent 2bf10c1 commit 4c44e7d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/webcontents-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,17 @@ function onLinkContextMenu(ev: Event, params: ContextMenuParams, webContents: We
label: _t("right_click_menu|save_image_as"),
accelerator: "s",
async click(): Promise<void> {
const targetFileName = params.suggestedFilename || params.altText || "image.png";
const originalFileName = params.suggestedFilename || params.altText || "image.png";
const timestamp = Date.now(); // Get current time in milliseconds
const ext = path.extname(originalFileName);
const baseName = path.basename(originalFileName, ext);
const targetFileName = `${baseName}-${timestamp}${ext}`;
const { filePath } = await dialog.showSaveDialog({
defaultPath: targetFileName,
});

if (!filePath) return; // user cancelled dialog

try {
if (url.startsWith("data:")) {
await writeNativeImage(filePath, nativeImage.createFromDataURL(url));
Expand Down

0 comments on commit 4c44e7d

Please sign in to comment.