-
Notifications
You must be signed in to change notification settings - Fork 456
/
main.js
50 lines (41 loc) · 1.23 KB
/
main.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
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import initializePlugins from 'lib/initializePlugins'
import { on } from 'lib/rpc'
import config from 'lib/config'
import { updateTerm } from './actions/search'
import store from './store'
import Cerebro from './components/Cerebro'
import './css/global.css'
global.React = React
global.ReactDOM = ReactDOM
global.isBackground = false
/**
* Change current theme
*
* @param {String} src Absolute path to new theme css file
*/
const changeTheme = (src) => {
document.getElementById('cerebro-theme').href = src
}
// Set theme from config
changeTheme(config.get('theme'))
// Render main container
ReactDOM.render(
<Provider store={store}>
<Cerebro />
</Provider>,
document.getElementById('root')
)
// Initialize plugins
initializePlugins()
// Handle `showTerm` rpc event and replace search term with payload
on('showTerm', (term) => store.dispatch(updateTerm(term)))
on('update-downloaded', () => (
new Notification('Cerebro: update is ready to install', {
body: 'New version is downloaded and will be automatically installed on quit'
})
))
// Handle `updateTheme` rpc event and change current theme
on('updateTheme', changeTheme)