mirror of
https://github.com/rhysd/Mstdn.git
synced 2025-01-21 20:52:11 +01:00
40 lines
1023 B
TypeScript
40 lines
1023 B
TypeScript
import {app, dialog} from 'electron';
|
|
import * as contextMenu from 'electron-context-menu';
|
|
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();
|
|
|
|
contextMenu();
|
|
|
|
const appReady = new Promise<void>(resolve => app.once('ready', resolve));
|
|
|
|
process.on('unhandledRejection', (reason: string) => {
|
|
const msg = 'FATAL: Unhandled rejection! Reason: ' + reason;
|
|
appReady.then(() =>
|
|
dialog.showMessageBox({
|
|
type: 'error',
|
|
buttons: ['OK'],
|
|
message: msg,
|
|
}, () => {
|
|
app.quit();
|
|
})
|
|
);
|
|
log.error(msg);
|
|
});
|
|
|
|
app.on('will-quit', () => {
|
|
log.debug('Application is quitting');
|
|
});
|
|
|
|
Promise.all([
|
|
loadConfig(),
|
|
appReady
|
|
]).then(([config, _]) => startApp(config)).then(mstdn => {
|
|
mstdn.start();
|
|
log.debug('Application launched!');
|
|
});
|