mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
549ce23ce8
* All projects into monorepo * Update CI * More CI updates * Extracted a bunch of things into packages * Publish - insomnia-plugin-base64@1.0.1 - insomnia-plugin-default-headers@1.0.2 - insomnia-plugin-file@1.0.1 - insomnia-plugin-hash@1.0.1 - insomnia-plugin-now@1.0.1 - insomnia-plugin-request@1.0.1 - insomnia-plugin-response@1.0.1 - insomnia-plugin-uuid@1.0.1 - insomnia-cookies@0.0.2 - insomnia-importers@1.5.2 - insomnia-prettify@0.0.3 - insomnia-url@0.0.2 - insomnia-xpath@0.0.2 * A bunch of small fixes * Improved build script * Fixed * Merge dangling files * Usability refactor * Handle duplicate plugin names
92 lines
2.4 KiB
JavaScript
92 lines
2.4 KiB
JavaScript
import * as React from 'react';
|
|
import ReactDOM from 'react-dom';
|
|
import {AppContainer} from 'react-hot-loader';
|
|
import {Provider} from 'react-redux';
|
|
import {DragDropContext} from 'react-dnd';
|
|
import App from './containers/app';
|
|
import * as models from '../models';
|
|
import * as db from '../common/database';
|
|
import {init as initStore} from './redux/modules';
|
|
import {init as initSync} from '../sync';
|
|
import {init as initPlugins} from '../plugins';
|
|
import DNDBackend from './dnd-backend';
|
|
import './css/index.less';
|
|
import {isDevelopment} from '../common/constants';
|
|
import {trackEvent, trackPageView} from '../common/analytics';
|
|
|
|
// Handy little helper
|
|
document.body.setAttribute('data-platform', process.platform);
|
|
|
|
(async function () {
|
|
await db.initClient();
|
|
|
|
// Create Redux store
|
|
const store = await initStore();
|
|
|
|
const context = DragDropContext(DNDBackend);
|
|
const DndComponent = context(App);
|
|
const render = Component => {
|
|
ReactDOM.render(
|
|
<AppContainer>
|
|
<Provider store={store}>
|
|
<Component/>
|
|
</Provider>
|
|
</AppContainer>,
|
|
document.getElementById('root')
|
|
);
|
|
};
|
|
|
|
render(DndComponent);
|
|
|
|
// Track the page view
|
|
trackPageView();
|
|
|
|
// Hot Module Replacement API
|
|
if (module.hot) {
|
|
module.hot.accept('./containers/app', () => {
|
|
render(DndComponent);
|
|
});
|
|
}
|
|
|
|
// Do things that can wait
|
|
process.nextTick(initSync);
|
|
process.nextTick(initPlugins);
|
|
})();
|
|
|
|
// Export some useful things for dev
|
|
if (isDevelopment()) {
|
|
window.models = models;
|
|
window.db = db;
|
|
}
|
|
|
|
// Catch uncaught errors and report them
|
|
if (window && !isDevelopment()) {
|
|
window.addEventListener('error', e => {
|
|
trackEvent('Error', 'Uncaught Error');
|
|
console.error('Uncaught Error', e);
|
|
});
|
|
|
|
window.addEventListener('unhandledRejection', e => {
|
|
trackEvent('Error', 'Uncaught Promise');
|
|
console.error('Unhandled Promise', e);
|
|
});
|
|
}
|
|
|
|
function showUpdateNotification () {
|
|
console.log('[app] Update Available');
|
|
|
|
// eslint-disable-next-line no-new
|
|
new window.Notification('Insomnia Update Ready', {
|
|
body: 'Relaunch the app for it to take effect',
|
|
silent: true,
|
|
sticky: true
|
|
});
|
|
}
|
|
|
|
const {ipcRenderer} = require('electron');
|
|
ipcRenderer.on('update-available', () => {
|
|
// Give it a few seconds before showing this. Sometimes, when
|
|
// you relaunch too soon it doesn't work the first time.
|
|
setTimeout(showUpdateNotification, 1000 * 10);
|
|
});
|