From 6594be9729754abab2e423a80d712b2c3b1337be Mon Sep 17 00:00:00 2001 From: "Hung Q. Le" Date: Fri, 2 Feb 2018 23:13:42 +0700 Subject: [PATCH 1/3] Moved center-on-primary-display to application (global) helpers --- app.js | 2 +- app/renderers/dialog.js | 2 +- {app/helpers => helpers}/center-on-primary-display.js | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {app/helpers => helpers}/center-on-primary-display.js (100%) diff --git a/app.js b/app.js index 7123f1da..2543265f 100644 --- a/app.js +++ b/app.js @@ -14,7 +14,7 @@ const { app, BrowserWindow, ipcMain } = require('electron'); const { autoUpdater } = require('electron-updater'); // Place a BrowserWindow in center of primary display -const centerOnPrimaryDisplay = require('./app/helpers/center-on-primary-display'); +const centerOnPrimaryDisplay = require('./helpers/center-on-primary-display'); // Prevent Linux GPU Bug // https://github.com/electron/electron/issues/4322 diff --git a/app/renderers/dialog.js b/app/renderers/dialog.js index d5e5ef29..21412fe4 100644 --- a/app/renderers/dialog.js +++ b/app/renderers/dialog.js @@ -8,7 +8,7 @@ const { BrowserWindow } = require('electron').remote; // Custom Libs const sounds = require('../../libs/sounds.js'); -const centerOnPrimaryDisplay = require('../helpers/center-on-primary-display'); +const centerOnPrimaryDisplay = require('../../helpers/center-on-primary-display'); function showModalWindow(dialogOptions, returnChannel = '', ...rest) { const width = 450; diff --git a/app/helpers/center-on-primary-display.js b/helpers/center-on-primary-display.js similarity index 100% rename from app/helpers/center-on-primary-display.js rename to helpers/center-on-primary-display.js From aaea3a7cb4e99a90eeadb4bd3b75d6bf98c6305a Mon Sep 17 00:00:00 2001 From: "Hung Q. Le" Date: Fri, 2 Feb 2018 23:14:48 +0700 Subject: [PATCH 2/3] Moved Notify helper to app helpers & updated path --- helpers/notify.js | 6 ++++++ preview/containers/MainContent.jsx | 2 +- preview/helper/notify.js | 9 --------- 3 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 helpers/notify.js delete mode 100644 preview/helper/notify.js diff --git a/helpers/notify.js b/helpers/notify.js new file mode 100644 index 00000000..f5dd387d --- /dev/null +++ b/helpers/notify.js @@ -0,0 +1,6 @@ +const Notify = ({ title, body }) => + new Notification(title, { + body, + }); + +module.exports = { Notify }; diff --git a/preview/containers/MainContent.jsx b/preview/containers/MainContent.jsx index c336089a..49653502 100644 --- a/preview/containers/MainContent.jsx +++ b/preview/containers/MainContent.jsx @@ -5,7 +5,7 @@ import { connect } from 'react-redux'; import { compose } from 'recompose'; import { translate } from 'react-i18next'; const ipc = require('electron').ipcRenderer; -import { Notify } from '../helper/notify'; +import { Notify } from '../../helpers/notify'; // Actions import * as ActionsCreator from '../actions'; diff --git a/preview/helper/notify.js b/preview/helper/notify.js deleted file mode 100644 index bfffe253..00000000 --- a/preview/helper/notify.js +++ /dev/null @@ -1,9 +0,0 @@ -function Notify(options) { - const{ title, body } = options; - return new Notification(title, { - body, - }); -} - -module.exports = { Notify }; - From 2c78d39b93ce754ceb86eececcdedc12b3cc4b9f Mon Sep 17 00:00:00 2001 From: "Hung Q. Le" Date: Fri, 2 Feb 2018 23:15:43 +0700 Subject: [PATCH 3/3] Send a Notification once the download is completed --- app/components/layout/AppUpdate.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/components/layout/AppUpdate.jsx b/app/components/layout/AppUpdate.jsx index 4fb2715e..3392f6b7 100644 --- a/app/components/layout/AppUpdate.jsx +++ b/app/components/layout/AppUpdate.jsx @@ -2,8 +2,9 @@ import React, { PureComponent } from 'react'; import openDialog from '../../renderers/dialog'; import { Circle } from 'rc-progress'; -const ipc = require('electron').ipcRenderer import i18n from '../../../i18n/i18n'; +import { Notify } from '../../../helpers/notify'; +const ipc = require('electron').ipcRenderer // Styled Components import styled, { keyframes } from 'styled-components'; @@ -104,6 +105,12 @@ class AppUpdate extends PureComponent { }); ipc.on('update-downloaded', () => { + // Send notification + Notify({ + title: i18n.t('dialog:appUpdate:downloaded:title'), + body: i18n.t('dialog:appUpdate:downloaded:message'), + }); + // Open Dialog openDialog( { type: 'info',