-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathindex.js
52 lines (45 loc) · 1.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import * as Sentry from '@sentry/electron'
import { createRoot } from 'react-dom/client'
import Restore from 'react-restore'
import App from './App'
import link from '../../resources/link'
import appStore from '../store'
Sentry.init({ dsn: 'https://7b09a85b26924609bef5882387e2c4dc@o1204372.ingest.sentry.io/6331069' })
document.addEventListener('dragover', (e) => e.preventDefault())
document.addEventListener('drop', (e) => e.preventDefault())
if (process.env.NODE_ENV !== 'development') {
window.eval = global.eval = () => {
throw new Error(`This app does not support window.eval()`)
}
}
function AppComponent() {
return <App />
}
link.rpc('getState', (err, state) => {
if (err) return console.error('Could not get initial state from main.')
const store = appStore(state)
link.send('tray:ready') // turn on api
link.send('tray:refreshMain')
store.observer(() => {
document.body.classList.remove('dark', 'light')
document.body.classList.add('clip', store('main.colorway'))
setTimeout(() => {
document.body.classList.remove('clip')
}, 100)
})
store.observer(() => {
if (store('tray.open')) {
document.body.classList.remove('suspend')
} else {
document.body.classList.add('suspend')
}
})
const root = createRoot(document.getElementById('tray'))
const Tray = Restore.connect(AppComponent, store)
root.render(<Tray />)
})
// document.addEventListener('mouseover', e => link.send('tray:focus'))
document.addEventListener('mouseout', (e) => {
if (e.clientX < 0) link.send('tray:mouseout')
})
document.addEventListener('contextmenu', (e) => link.send('*:contextmenu', e.clientX, e.clientY))