Skip to content

Commit

Permalink
Merge pull request #4 from kawmra/improve-check-for-update-notification
Browse files Browse the repository at this point in the history
Notify the result of check-for-update even if it fails
  • Loading branch information
kawmra authored May 4, 2019
2 parents 0e1c8e2 + bbe738a commit d9de97e
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/presentation/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,34 @@ function shouldCheckForUpdate() {

async function checkForUpdateIfNeeded(forced: boolean = false) {
if (forced || shouldCheckForUpdate()) {
const updates = await checkForUpdate()
if (updates && updates.canUpdate) {
notifyUpdateFound(updates.release)
const updates = await checkForUpdate().catch(() => { null })
if (updates) {
if (updates.canUpdate) {
notifyUpdateFound(updates.release)
} else if (forced) {
notifyNoUpdateFound()
}
} else if (forced) {
notifyFailedToCheckForUpdate()
}
lastTimeCheckedForUpdate = new Date().getTime()
}
}

function notifyFailedToCheckForUpdate() {
new Notification({
title: 'Failed to check for update',
body: 'Please try again after a while.'
}).show()
}

function notifyNoUpdateFound() {
new Notification({
title: 'No Update found',
body: 'Your Owl Timekeeper is up-to-date'
}).show()
}

function notifyUpdateFound(release: Release) {
if (lastNotification) {
lastNotification.close()
Expand Down

0 comments on commit d9de97e

Please sign in to comment.