From 765f712ea10764e45d976c768edb6cab3bce2274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madis=20Va=CC=88in?= Date: Sat, 26 Sep 2020 09:49:38 +0300 Subject: [PATCH] fix invoice to pdf filename --- src/main/index.js | 5 +++-- src/pages/invoices/$id/pdf.js | 11 +++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index b03906b..d69a089 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,4 +1,4 @@ -import { app, BrowserWindow, ipcMain, shell, dialog } from 'electron'; +import { app, BrowserWindow, ipcMain, dialog } from 'electron'; import { autoUpdater } from 'electron-updater'; import * as path from 'path'; import * as url from 'url'; @@ -113,7 +113,8 @@ ipcMain.on('readyToPrint', (event, filename) => { if (error) { event.sender.send('wrotePDF'); } - shell.openItem(filePath); + // TODO: Causes an exception on OSX + // shell.openItem(filePath); event.sender.send('wrotePDF'); }); }) diff --git a/src/pages/invoices/$id/pdf.js b/src/pages/invoices/$id/pdf.js index 6ba3bbe..ce11a7a 100644 --- a/src/pages/invoices/$id/pdf.js +++ b/src/pages/invoices/$id/pdf.js @@ -92,13 +92,12 @@ class Invoice extends Component { if (get(this.props, ['match', 'path'], '').endsWith('pdf')) { const { ipcRenderer } = window.require('electron'); - const { invoices } = this.props; - const invoice = get(invoices.items, get(this.props, ['match', 'params', 'id'])); + setTimeout(() => { + const { invoices } = this.props; + const invoice = get(invoices.items, get(this.props, ['match', 'params', 'id'])); - setTimeout( - () => ipcRenderer.send('readyToPrint', `Invoice ${get(invoice, 'number')}.pdf`), - 200 - ); + ipcRenderer.send('readyToPrint', `Invoice ${get(invoice, 'number')}.pdf`); + }, 200); } }