1
0
mirror of https://github.com/rhysd/Mstdn.git synced 2025-01-21 20:52:11 +01:00
Mstdn/main/index.ts

40 lines
1023 B
TypeScript
Raw Normal View History

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';
// 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-04-15 16:32:44 +09:00
const appReady = new Promise<void>(resolve => app.once('ready', resolve));
process.on('unhandledRejection', (reason: string) => {
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 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
]).then(([config, _]) => startApp(config)).then(mstdn => {
mstdn.start();
2017-04-15 16:32:44 +09:00
log.debug('Application launched!');
});