diff options
author | 2022-06-22 16:21:23 +0200 | |
---|---|---|
committer | 2022-06-23 17:50:07 +0530 | |
commit | caf43fc8d64c27a1aad4a5d6507313c513c1a447 (patch) | |
tree | c0a7bcb950cdf555b3e8a33a57e2241e7051861d /src/app.jsx | |
parent | Workaroud for in-app Password Recovery (#342) (diff) | |
download | ferdium-app-caf43fc8d64c27a1aad4a5d6507313c513c1a447.tar.gz ferdium-app-caf43fc8d64c27a1aad4a5d6507313c513c1a447.tar.zst ferdium-app-caf43fc8d64c27a1aad4a5d6507313c513c1a447.zip |
chore: featureStore and GlobalErrorStore JS => TS
Diffstat (limited to 'src/app.jsx')
-rw-r--r-- | src/app.jsx | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/app.jsx b/src/app.jsx new file mode 100644 index 000000000..db0dee392 --- /dev/null +++ b/src/app.jsx | |||
@@ -0,0 +1,65 @@ | |||
1 | import { webFrame } from 'electron'; | ||
2 | |||
3 | import { render } from 'react-dom'; | ||
4 | import { Provider } from 'mobx-react'; | ||
5 | import { syncHistoryWithStore, RouterStore } from 'mobx-react-router'; | ||
6 | import { hashHistory } from 'react-router'; | ||
7 | |||
8 | import ServerApi from './api/server/ServerApi'; | ||
9 | import LocalApi from './api/server/LocalApi'; | ||
10 | import storeFactory from './stores'; | ||
11 | import apiFactory from './api'; | ||
12 | import actions from './actions'; | ||
13 | import MenuFactory from './lib/Menu'; | ||
14 | import TouchBarFactory from './lib/TouchBar'; | ||
15 | |||
16 | import I18N from './I18n'; | ||
17 | import Routes from './routes'; | ||
18 | |||
19 | // Basic electron Setup | ||
20 | webFrame.setVisualZoomLevelLimits(1, 1); | ||
21 | |||
22 | window.addEventListener('load', () => { | ||
23 | const serverApi = new ServerApi(); | ||
24 | const api = apiFactory(serverApi, new LocalApi()); | ||
25 | const router = new RouterStore(); | ||
26 | const stores = storeFactory(api, actions, router); | ||
27 | const history = syncHistoryWithStore(hashHistory, router); | ||
28 | const menu = new MenuFactory(stores, actions); | ||
29 | const touchBar = new TouchBarFactory(stores, actions); | ||
30 | |||
31 | window['ferdium'] = { | ||
32 | stores, | ||
33 | actions, | ||
34 | api, | ||
35 | menu, | ||
36 | touchBar, | ||
37 | features: {}, | ||
38 | render() { | ||
39 | const preparedApp = ( | ||
40 | <Provider stores={stores} actions={actions}> | ||
41 | <I18N stores={{ app: stores.app, user: stores.user }}> | ||
42 | <Routes history={history} /> | ||
43 | </I18N> | ||
44 | </Provider> | ||
45 | ); | ||
46 | render(preparedApp, document.querySelector('#root')); | ||
47 | }, | ||
48 | }; | ||
49 | window['ferdium'].render(); | ||
50 | }); | ||
51 | |||
52 | // Prevent back and forward mouse events for the app itself (not inside the recipe) | ||
53 | // TODO: send this request to the recipe.js | ||
54 | window.addEventListener('mouseup', e => { | ||
55 | if (e.button === 3 || e.button === 4) { | ||
56 | e.preventDefault(); | ||
57 | e.stopPropagation(); | ||
58 | } | ||
59 | }); | ||
60 | |||
61 | // Prevent drag and drop into window from redirecting | ||
62 | window.addEventListener('dragover', event => event.preventDefault()); | ||
63 | window.addEventListener('drop', event => event.preventDefault()); | ||
64 | window.addEventListener('dragover', event => event.stopPropagation()); | ||
65 | window.addEventListener('drop', event => event.stopPropagation()); | ||