1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-24 23:23:09 +00:00

using ipc but not working in production

This commit is contained in:
Rokt33r
2015-11-24 02:54:45 +09:00
parent de3b76b31d
commit e5a2bfbcbd
6 changed files with 160 additions and 61 deletions

View File

@@ -16,11 +16,8 @@ export function searchArticle (input) {
}
}
export function refreshData () {
export function refreshData (data) {
console.log('refreshing data')
let data = JSON.parse(localStorage.getItem('local'))
if (data == null) return null
let { folders, articles } = data
return {

View File

@@ -8,10 +8,10 @@ import FinderList from './FinderList'
import FinderDetail from './FinderDetail'
import { selectArticle, searchArticle, refreshData } from './actions'
import _ from 'lodash'
import activityRecord from 'boost/activityRecord'
const electron = require('electron')
const { remote, clipboard } = electron
const ipc = electron.ipcRenderer
var hideFinder = remote.getGlobal('hideFinder')
@@ -63,7 +63,6 @@ class FinderMain extends React.Component {
saveToClipboard () {
let { activeArticle } = this.props
clipboard.writeText(activeArticle.content)
activityRecord.emit('FINDER_COPY')
notify('Saved to Clipboard!', {
body: 'Paste it wherever you want!'
@@ -214,10 +213,13 @@ var Finder = connect(remap)(FinderMain)
var store = createStore(reducer)
window.onfocus = e => {
store.dispatch(refreshData())
activityRecord.emit('FINDER_OPEN')
ipc.send('request-data')
}
ipc.on('refresh-data', function (e, data) {
store.dispatch(refreshData(data))
})
ReactDOM.render((
<Provider store={store}>
<Finder/>

View File

@@ -1,10 +1,8 @@
import { combineReducers } from 'redux'
import { SELECT_ARTICLE, SEARCH_ARTICLE, REFRESH_DATA } from './actions'
let data = JSON.parse(localStorage.getItem('local'))
let initialArticles = data != null ? data.articles : []
let initialFolders = data != null ? data.folders : []
let initialArticles = []
let initialFolders = []
let initialStatus = {
articleKey: null,
search: ''

View File

@@ -11,6 +11,7 @@ require('../styles/main/index.styl')
import { openModal } from 'boost/modal'
import Tutorial from 'boost/components/modal/Tutorial'
import activityRecord from 'boost/activityRecord'
import dataStore from 'boost/dataStore'
const electron = require('electron')
const ipc = electron.ipcRenderer
@@ -29,6 +30,10 @@ ipc.on('notify', function (title, message) {
})
})
ipc.on('request-data', function () {
ipc.send('refresh-data', dataStore.getData())
})
let routes = (
<Route path='/' component={MainPage}>
<IndexRoute name='home' component={HomePage}/>