mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 05:58:41 -09:00
electron auotupdater
This commit is contained in:
parent
20aa12d526
commit
461f7d9430
3 changed files with 57 additions and 4 deletions
|
|
@ -41,6 +41,7 @@ export default class HyperTerm extends Component {
|
||||||
this.onResize = this.onResize.bind(this);
|
this.onResize = this.onResize.bind(this);
|
||||||
this.onChange = this.onChange.bind(this);
|
this.onChange = this.onChange.bind(this);
|
||||||
this.openExternal = this.openExternal.bind(this);
|
this.openExternal = this.openExternal.bind(this);
|
||||||
|
this.quitAndInstall = this.quitAndInstall.bind(this);
|
||||||
this.focusActive = this.focusActive.bind(this);
|
this.focusActive = this.focusActive.bind(this);
|
||||||
this.closeBrowser = this.closeBrowser.bind(this);
|
this.closeBrowser = this.closeBrowser.bind(this);
|
||||||
this.onHeaderMouseDown = this.onHeaderMouseDown.bind(this);
|
this.onHeaderMouseDown = this.onHeaderMouseDown.bind(this);
|
||||||
|
|
@ -98,13 +99,23 @@ export default class HyperTerm extends Component {
|
||||||
<div>{ this.state.cols }x{ this.state.rows }</div>
|
<div>{ this.state.cols }x{ this.state.rows }</div>
|
||||||
</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>).
|
Version <b>{ this.state.updateVersion }</b> ready.
|
||||||
{this.state.updateNote ? ` ${this.state.updateNote}. ` : ' '}
|
{this.state.updateNote ? ` ${this.state.updateNote}. ` : ' '}
|
||||||
<a href='https://hyperterm.now.sh' onClick={this.openExternal} target='_blank'>Download</a>
|
<a href='' onClick={this.quitAndInstall}>Restart</a>
|
||||||
|
to apply <span className='close' onClick={this.quitAndInstall}>[x]</span>
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quitAndInstall (ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
this.rpc.emit('quit-and-install');
|
||||||
|
}
|
||||||
|
|
||||||
|
closeUpdateIndicator () {
|
||||||
|
// @TODO
|
||||||
|
}
|
||||||
|
|
||||||
openExternal (ev) {
|
openExternal (ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
this.rpc.emit('open external', { url: ev.target.href });
|
this.rpc.emit('open external', { url: ev.target.href });
|
||||||
|
|
@ -240,6 +251,13 @@ export default class HyperTerm extends Component {
|
||||||
this.rpc.on('increase font size', this.increaseFontSize);
|
this.rpc.on('increase font size', this.increaseFontSize);
|
||||||
this.rpc.on('decrease font size', this.decreaseFontSize);
|
this.rpc.on('decrease font size', this.decreaseFontSize);
|
||||||
this.rpc.on('reset font size', this.resetFontSize);
|
this.rpc.on('reset font size', this.resetFontSize);
|
||||||
|
|
||||||
|
this.rpc.once('update-available', (data) => {
|
||||||
|
// hardcoded data for now
|
||||||
|
const updateVersion = '3.0.1';
|
||||||
|
const updateNote = '';
|
||||||
|
this.setState({ updateVersion, updateNote });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCurrentTerm () {
|
clearCurrentTerm () {
|
||||||
|
|
@ -249,8 +267,8 @@ export default class HyperTerm extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdateAvailable (updateVersion, updateNote = '') {
|
onUpdateAvailable (updateVersion, updateNote = '') {
|
||||||
updateNote = updateNote.replace(/\.$/, '');
|
// updateNote = updateNote.replace(/\.$/, '');
|
||||||
this.setState({ updateVersion, updateNote });
|
// this.setState({ updateVersion, updateNote });
|
||||||
}
|
}
|
||||||
|
|
||||||
moveTo (n) {
|
moveTo (n) {
|
||||||
|
|
|
||||||
32
auto-updater.js
Normal file
32
auto-updater.js
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
const { autoUpdater, dialog } = require('electron');
|
||||||
|
// const { version } = require('./package');
|
||||||
|
const version = '0.3.0'; // to force update available
|
||||||
|
|
||||||
|
const FEED_URL = 'https://nuts-serve-nxchetcjig.now.sh/update/osx';
|
||||||
|
|
||||||
|
module.exports = function AutoUpdater (rpc) {
|
||||||
|
autoUpdater.on('error', (err, msg) => {
|
||||||
|
dialog.showMessageBox({title: 'title', message: JSON.stringify(err), buttons: ['Ok error']});
|
||||||
|
dialog.showMessageBox({title: 'title', message: JSON.stringify(msg), buttons: ['Ok error']});
|
||||||
|
});
|
||||||
|
|
||||||
|
autoUpdater.setFeedURL(`${FEED_URL}/${version}`);
|
||||||
|
|
||||||
|
autoUpdater.once('update-downloaded', () => {
|
||||||
|
rpc.emit('update-available');
|
||||||
|
});
|
||||||
|
|
||||||
|
autoUpdater.once('update-available', () => {
|
||||||
|
dialog.showMessageBox({title: 'title', message: 'update-available', buttons: ['Ok']});
|
||||||
|
});
|
||||||
|
|
||||||
|
autoUpdater.once('update-not-available', () => {
|
||||||
|
dialog.showMessageBox({title: 'title', message: 'update-not-available', buttons: ['Ok']});
|
||||||
|
});
|
||||||
|
|
||||||
|
rpc.once('quit-and-install', () => {
|
||||||
|
autoUpdater.quitAndInstall();
|
||||||
|
});
|
||||||
|
|
||||||
|
autoUpdater.checkForUpdates();
|
||||||
|
};
|
||||||
3
index.js
3
index.js
|
|
@ -5,6 +5,7 @@ const Session = require('./session');
|
||||||
const genUid = require('uid2');
|
const genUid = require('uid2');
|
||||||
const { resolve } = require('path');
|
const { resolve } = require('path');
|
||||||
const isDev = require('electron-is-dev');
|
const isDev = require('electron-is-dev');
|
||||||
|
const AutoUpdater = require('./auto-updater');
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
console.log('running in dev mode');
|
console.log('running in dev mode');
|
||||||
|
|
@ -59,6 +60,8 @@ app.on('ready', () => {
|
||||||
sessions.set(uid, session);
|
sessions.set(uid, session);
|
||||||
rpc.emit('new session', { uid });
|
rpc.emit('new session', { uid });
|
||||||
|
|
||||||
|
AutoUpdater(rpc);
|
||||||
|
|
||||||
session.on('data', (data) => {
|
session.on('data', (data) => {
|
||||||
rpc.emit('data', { uid, data });
|
rpc.emit('data', { uid, data });
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue