From 08a106312d021d688553c2e2bc3e5744431651a3 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 7 Jul 2016 00:13:53 -0700 Subject: [PATCH] remove old updater and add update dismissing --- app/hyperterm.js | 12 ++++++--- app/update-checker.js | 61 ------------------------------------------- 2 files changed, 8 insertions(+), 65 deletions(-) delete mode 100644 app/update-checker.js diff --git a/app/hyperterm.js b/app/hyperterm.js index 451fa624..ac727fa9 100644 --- a/app/hyperterm.js +++ b/app/hyperterm.js @@ -5,7 +5,6 @@ import Mousetrap from 'mousetrap'; import classes from 'classnames'; import shallowCompare from 'react-addons-shallow-compare'; import React, { Component } from 'react'; -import UpdateChecker from './update-checker'; export default class HyperTerm extends Component { constructor () { @@ -23,8 +22,8 @@ export default class HyperTerm extends Component { mac: /Mac/.test(navigator.userAgent), resizeIndicatorShowing: false, fontSizeIndicatorShowing: false, + dismissedUpdate: false, updateVersion: null, - updateNote: null, fontSize: 12 }; @@ -52,6 +51,7 @@ export default class HyperTerm extends Component { this.resetFontSize = this.resetFontSize.bind(this); this.increaseFontSize = this.increaseFontSize.bind(this); this.decreaseFontSize = this.decreaseFontSize.bind(this); + this.dismissUpdate = this.dismissUpdate.bind(this); } render () { @@ -98,15 +98,19 @@ export default class HyperTerm extends Component { {this.state.fontSizeIndicatorShowing &&
{ this.state.fontSize }px
}
{ this.state.cols }x{ this.state.rows }
-
+
Version { this.state.updateVersion } ready. {this.state.updateNote ? ` ${this.state.updateNote}. ` : ' '} Restart - to apply [x] + to apply [x]
; } + dismissUpdate () { + this.setState({ dismissedUpdate: true }); + } + quitAndInstall (ev) { ev.preventDefault(); this.rpc.emit('quit-and-install'); diff --git a/app/update-checker.js b/app/update-checker.js deleted file mode 100644 index 785b0bd7..00000000 --- a/app/update-checker.js +++ /dev/null @@ -1,61 +0,0 @@ -/*global fetch:false*/ -import { version as currentVersion } from '../package'; -import compare from 'semver-compare'; -import ms from 'ms'; - -const DEFAULT_INTERVAL = ms('5m'); - -export default class UpdateChecker { - - constructor (fn, { interval = DEFAULT_INTERVAL } = {}) { - this.callback = fn; - this.interval = interval; - this.check(); - this.lastKnown = null; - } - - check () { - const done = () => { - this.checkTimer = setTimeout(() => { - this.check(); - }, this.interval); - }; - - console.log('checking for update'); - fetch('https://hyperterm.now.sh/updates.json') - .then((res) => { - if (200 !== res.status) { - console.error('Update check error. Status (%d)', res.status); - return done(); - } - - res.json() - .then(({ version, note }) => { - if (this.lastKnown !== version) { - this.lastKnown = version; - - if (1 === compare(version, currentVersion)) { - console.log('update found'); - this.callback(version, note); - } else { - console.log('no update. latest:', version); - } - } - done(); - }) - .catch((err) => { - console.error('Update JSON parse error', err.stack); - done(); - }); - }).catch((err) => { - console.error('Update check error', err.stack); - done(); - }); - } - - destroy () { - this.aborted = true; - clearTimeout(this.checkTimer); - } - -}