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

Commit

Permalink
open contribution PDF after saving
Browse files Browse the repository at this point in the history
for issue #6039
(depends on #2714 , possibly fixed in #6330)
  • Loading branch information
Willy Bruns committed Dec 22, 2016
1 parent d04d93a commit 2c4afcf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions app/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const Tabs = require('./browser/tabs')
const {fileUrl} = require('../js/lib/appUrlUtil')

const renderUrlToPdf = (appState, action, testingMode) => {
let url = action.url
let savePath = action.savePath
let openAfterwards = action.openAfterwards

let currentBw = BrowserWindow.getFocusedWindow()

let bw = new BrowserWindow({show: !!testingMode, backgroundColor: '#ffffff'})

let wv = bw.webContents
Expand Down Expand Up @@ -41,15 +41,15 @@ const renderUrlToPdf = (appState, action, testingMode) => {
if (state === 'completed') {
let finalSavePath = item && item.getSavePath()

if (openAfterwards && savePath) {
currentBw.webContents.loadURL('file://' + finalSavePath)
}

if (bw && !testingMode) {
try {
bw.close()
} catch (exc) {}
}

if (openAfterwards && finalSavePath) {
Tabs.create({url: fileUrl(finalSavePath)})
}
}
})
})
Expand Down
5 changes: 3 additions & 2 deletions js/about/aboutActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,12 @@ const aboutActions = {
/**
* Dispatches a message to render a URL into a PDF file
*/
renderUrlToPdf: function (url, savePath) {
renderUrlToPdf: function (url, savePath, openAfterwards) {
aboutActions.dispatchAction({
actionType: appConstants.APP_RENDER_URL_TO_PDF,
url: url,
savePath: savePath
savePath: savePath,
openAfterwards: openAfterwards
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/about/contributionStatement.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class ContributionStatement extends ImmutableComponent {
}

renderPdf () {
aboutActions.renderUrlToPdf(this.htmlDataURL, this.receiptFileName())
aboutActions.renderUrlToPdf(this.htmlDataURL, this.receiptFileName(), true)
}

get transaction () {
Expand Down

0 comments on commit 2c4afcf

Please sign in to comment.