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

Open brave payments contrib pdf in PDF.js after generated (WIP) #6385

Closed
wants to merge 2 commits into from
Closed
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
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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -280,7 +280,7 @@ class ContributionStatement extends ImmutableComponent {
<tr className='spacingRow' />
{
page.map(function (row, idx) {
let publisherSynopsis = this.synopsis[row.siteColumn] || {}
let publisherSynopsis = (this.synopsis.filter((entry) => { return entry.site === row[0] }) || [])[0] || {}

let verified = publisherSynopsis.verified
let site = row[0]
Expand Down