2017-04-20 10:48:29 +09:00
|
|
|
import {app, dialog} from 'electron';
|
2017-05-08 02:13:56 +09:00
|
|
|
import * as contextMenu from 'electron-context-menu';
|
2017-04-15 16:32:44 +09:00
|
|
|
import log from './log';
|
|
|
|
import startApp from './app';
|
|
|
|
import loadConfig from './config';
|
|
|
|
|
2017-04-18 20:29:07 +09:00
|
|
|
// default_app sets app.on('all-window-closed', () => app.quit()) before
|
|
|
|
// loading this application. We need to disable the callback.
|
|
|
|
app.removeAllListeners();
|
|
|
|
|
2017-05-08 02:13:56 +09:00
|
|
|
contextMenu();
|
2017-05-03 17:27:39 +02:00
|
|
|
|
2017-04-15 16:32:44 +09:00
|
|
|
const appReady = new Promise<void>(resolve => app.once('ready', resolve));
|
|
|
|
|
|
|
|
process.on('unhandledRejection', (reason: string) => {
|
2017-04-20 12:11:10 +09:00
|
|
|
const msg = 'FATAL: Unhandled rejection! Reason: ' + reason;
|
|
|
|
appReady.then(() =>
|
2017-04-20 10:48:29 +09:00
|
|
|
dialog.showMessageBox({
|
|
|
|
type: 'error',
|
|
|
|
buttons: ['OK'],
|
|
|
|
message: msg,
|
|
|
|
}, () => {
|
2017-04-20 11:09:57 +09:00
|
|
|
app.quit();
|
2017-04-20 10:48:29 +09:00
|
|
|
})
|
2017-04-20 12:11:10 +09:00
|
|
|
);
|
2017-04-20 10:48:29 +09:00
|
|
|
log.error(msg);
|
2017-04-15 16:32:44 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
app.on('will-quit', () => {
|
|
|
|
log.debug('Application is quitting');
|
|
|
|
});
|
|
|
|
|
|
|
|
Promise.all([
|
|
|
|
loadConfig(),
|
|
|
|
appReady
|
2017-04-18 20:29:07 +09:00
|
|
|
]).then(([config, _]) => startApp(config)).then(mstdn => {
|
|
|
|
mstdn.start();
|
2017-04-15 16:32:44 +09:00
|
|
|
log.debug('Application launched!');
|
|
|
|
});
|