Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Prompt to save #1198

Merged
merged 8 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion app/background-process/ui/downloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ export function registerListener (win, opts = {}) {
}

downloads.push(item)
downloadsEvents.emit('new-download', toJSON(item))

// This is to prevent the browser-dropdown-menu from opening
// For now it is being used when downloading `.html` pages
if (!opts.suppressNewDownloadEvent) {
downloadsEvents.emit('new-download', toJSON(item))
}

// update dock-icon progress bar
var lastBytes = 0
Expand Down
6 changes: 5 additions & 1 deletion app/background-process/ui/window-menu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as beakerCore from '@beaker/core'
import { app, BrowserWindow, dialog, ipcMain, Menu } from 'electron'
import { createShellWindow, getFocusedDevToolsHost } from './windows'
import download from './downloads'

// exported APIs
// =
Expand Down Expand Up @@ -116,7 +117,10 @@ export function buildWindowMenu (opts = {}) {
accelerator: 'CmdOrCtrl+S',
click: async (item, win) => {
const url = await win.webContents.executeJavaScript(`pages.getActive().getIntendedURL()`)
win.webContents.downloadURL(url, true)
const title = await win.webContents.executeJavaScript(`pages.getActive().title`)
dialog.showSaveDialog({ title: `Save ${title} as...`, defaultPath: app.getPath('downloads') }, filepath => {
if (filepath) download(win, win.webContents, url, { saveAs: filepath, suppressNewDownloadEvent: true })
})
}
},
{
Expand Down