improvements to update checker

This commit is contained in:
Guillermo Rauch 2016-07-03 15:12:35 -07:00
parent bf164eabca
commit 45292f33d5
2 changed files with 9 additions and 7 deletions

View file

@ -22,7 +22,8 @@ export default class HyperTerm extends Component {
activeMarkers: [], activeMarkers: [],
mac: /Mac/.test(navigator.userAgent), mac: /Mac/.test(navigator.userAgent),
resizeIndicatorShowing: false, resizeIndicatorShowing: false,
updateVersion: null updateVersion: null,
updateNote: null
}; };
// we set this to true when the first tab // we set this to true when the first tab
@ -89,7 +90,7 @@ export default class HyperTerm extends Component {
</div> </div>
<div className={classes('update-indicator', { showing: null !== this.state.updateVersion })}> <div className={classes('update-indicator', { showing: null !== this.state.updateVersion })}>
Update available (<b>{ this.state.updateVersion }</b>). Update available (<b>{ this.state.updateVersion }</b>).
{' '} {this.state.updateNote ? ` ${this.state.updateNote}. ` : ' '}
<a href='https://hyperterm.now.sh' onClick={this.openExternal} target='_blank'>Download</a> <a href='https://hyperterm.now.sh' onClick={this.openExternal} target='_blank'>Download</a>
</div> </div>
</div>; </div>;
@ -231,8 +232,9 @@ export default class HyperTerm extends Component {
term.clear(); term.clear();
} }
onUpdateAvailable (updateVersion) { onUpdateAvailable (updateVersion, updateNote = '') {
this.setState({ updateVersion }); updateNote = updateNote.replace(/\.$/, '');
this.setState({ updateVersion, updateNote });
} }
moveTo (n) { moveTo (n) {

View file

@ -19,7 +19,7 @@ export default class UpdateChecker {
}; };
console.log('checking for update'); console.log('checking for update');
fetch('https://hyperterm.now.sh/data.json') fetch('https://hyperterm.now.sh/updates.json')
.then((res) => { .then((res) => {
if (200 !== res.status) { if (200 !== res.status) {
console.error('Update check error. Status (%d)', res.status); console.error('Update check error. Status (%d)', res.status);
@ -27,13 +27,13 @@ export default class UpdateChecker {
} }
res.json() res.json()
.then(({ version }) => { .then(({ version, note }) => {
if (this.lastKnown !== version) { if (this.lastKnown !== version) {
this.lastKnown = version; this.lastKnown = version;
if (1 === compare(version, currentVersion)) { if (1 === compare(version, currentVersion)) {
console.log('update found'); console.log('update found');
this.callback(version); this.callback(version, note);
} else { } else {
console.log('no update. latest:', version); console.log('no update. latest:', version);
} }