-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dcb069
commit cefc4ee
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Packages | ||
const { shell, Notification } = require('electron') | ||
const { resolve } = require('app-root-path') | ||
|
||
const icon = resolve('./static/icon.ico') | ||
|
||
module.exports = ({ title, body, url, onClick }) => { | ||
const specs = { | ||
title, | ||
body, | ||
icon, | ||
silent: true | ||
} | ||
|
||
const notification = new Notification(specs) | ||
|
||
if (url || onClick) { | ||
notification.on('click', () => { | ||
if (onClick) { | ||
return onClick() | ||
} | ||
|
||
shell.openExternal(url) | ||
}) | ||
} | ||
|
||
notification.show() | ||
console.log(`[Notification] ${title}: ${body}`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
'use strict' | ||
|
||
// Packages | ||
const { app, autoUpdater } = require('electron') | ||
const isDev = require('electron-is-dev') | ||
|
||
// Utils | ||
const notify = require('./notify') | ||
|
||
module.exports = () => { | ||
if (!isDev) { | ||
const server = 'https://taskr.now.sh' | ||
const feed = `${server}/update/${process.platform}/${app.getVersion()}` | ||
|
||
autoUpdater.setFeedURL(feed) | ||
|
||
return autoUpdater.getFeedURL() | ||
autoUpdater.on('update-downloaded', () => { | ||
autoUpdater.quitAndInstall() | ||
app.quit() | ||
}) | ||
|
||
autoUpdater.on('update-available', () => { | ||
notify({ | ||
title: 'New update available', | ||
body: 'Found update for the app! Downloading...' | ||
}) | ||
}) | ||
|
||
return autoUpdater.checkForUpdates() | ||
} | ||
} |