Skip to content

Commit b6212f4

Browse files
AWolf81Rokt33r
authored andcommitted
Update dependencies & change to React-router v5
1 parent 76335f7 commit b6212f4

29 files changed

+668
-271
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"test": {
88
"presets": ["env" ,"react", "es2015"],
99
"plugins": [
10-
[ "babel-plugin-webpack-alias", { "config": "${PWD}/webpack.config.js" } ]
10+
[ "babel-plugin-webpack-alias", { "config": "<rootDir>/webpack.config.js" } ]
1111
]
1212
}
1313
}

browser/lib/CSSModules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import CSSModules from 'react-css-modules'
22

33
export default function (component, styles) {
4-
return CSSModules(component, styles, {errorWhenNotFound: false})
4+
return CSSModules(component, styles, {handleNotFoundStyleName: 'log'})
55
}

browser/lib/newNote.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { hashHistory } from 'react-router'
1+
// import { hashHistory } from 'react-router'
2+
import { history } from 'browser/main/store'
23
import dataApi from 'browser/main/lib/dataApi'
34
import ee from 'browser/main/lib/eventEmitter'
45
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
6+
import queryString from 'query-string'
57

68
export function createMarkdownNote (storage, folder, dispatch, location, params, config) {
79
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
@@ -28,9 +30,9 @@ export function createMarkdownNote (storage, folder, dispatch, location, params,
2830
note: note
2931
})
3032

31-
hashHistory.push({
33+
history.push({
3234
pathname: location.pathname,
33-
query: { key: noteHash }
35+
search: queryString.stringify({ key: noteHash })
3436
})
3537
ee.emit('list:jump', noteHash)
3638
ee.emit('detail:focus')
@@ -70,9 +72,9 @@ export function createSnippetNote (storage, folder, dispatch, location, params,
7072
type: 'UPDATE_NOTE',
7173
note: note
7274
})
73-
hashHistory.push({
75+
history.push({
7476
pathname: location.pathname,
75-
query: { key: noteHash }
77+
search: queryString.stringify({ key: noteHash })
7678
})
7779
ee.emit('list:jump', noteHash)
7880
ee.emit('detail:focus')

browser/main/Detail/MarkdownNoteDetail.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import StarButton from './StarButton'
99
import TagSelect from './TagSelect'
1010
import FolderSelect from './FolderSelect'
1111
import dataApi from 'browser/main/lib/dataApi'
12-
import { hashHistory } from 'react-router'
12+
// import { hashHistory } from 'react-router'
13+
import { history } from 'browser/main/store'
1314
import ee from 'browser/main/lib/eventEmitter'
1415
import markdown from 'browser/lib/markdownTextHelper'
1516
import StatusBar from '../StatusBar'
@@ -30,6 +31,7 @@ import { getTodoPercentageOfCompleted } from 'browser/lib/getTodoStatus'
3031
import striptags from 'striptags'
3132
import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote'
3233
import markdownToc from 'browser/lib/markdown-toc-generator'
34+
import queryString from 'query-string'
3335

3436
class MarkdownNoteDetail extends React.Component {
3537
constructor (props) {
@@ -159,11 +161,11 @@ class MarkdownNoteDetail extends React.Component {
159161
originNote: note,
160162
note: newNote
161163
})
162-
hashHistory.replace({
164+
history.replace({
163165
pathname: location.pathname,
164-
query: {
166+
search: queryString.stringify({
165167
key: newNote.key
166-
}
168+
})
167169
})
168170
this.setState({
169171
isMovingNote: false
@@ -491,7 +493,7 @@ class MarkdownNoteDetail extends React.Component {
491493
<InfoPanel
492494
storageName={currentOption.storage.name}
493495
folderName={currentOption.folder.name}
494-
noteLink={`[${note.title}](:note:${location.query.key})`}
496+
noteLink={`[${note.title}](:note:${queryString.parse(location.search).key})`}
495497
updatedAt={formatDate(note.updatedAt)}
496498
createdAt={formatDate(note.createdAt)}
497499
exportAsMd={this.exportAsMd}

browser/main/Detail/SnippetNoteDetail.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import StarButton from './StarButton'
88
import TagSelect from './TagSelect'
99
import FolderSelect from './FolderSelect'
1010
import dataApi from 'browser/main/lib/dataApi'
11-
import {hashHistory} from 'react-router'
11+
// import {hashHistory} from 'react-router'
12+
import { history } from 'browser/main/store'
1213
import ee from 'browser/main/lib/eventEmitter'
1314
import CodeMirror from 'codemirror'
1415
import 'codemirror-mode-elixir'
@@ -18,7 +19,6 @@ import context from 'browser/lib/context'
1819
import ConfigManager from 'browser/main/lib/ConfigManager'
1920
import _ from 'lodash'
2021
import {findNoteTitle} from 'browser/lib/findNoteTitle'
21-
import convertModeName from 'browser/lib/convertModeName'
2222
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
2323
import FullscreenButton from './FullscreenButton'
2424
import TrashButton from './TrashButton'
@@ -31,6 +31,7 @@ import { formatDate } from 'browser/lib/date-formatter'
3131
import i18n from 'browser/lib/i18n'
3232
import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote'
3333
import markdownToc from 'browser/lib/markdown-toc-generator'
34+
import queryString from 'query-string'
3435

3536
const electron = require('electron')
3637
const { remote } = electron
@@ -166,11 +167,11 @@ class SnippetNoteDetail extends React.Component {
166167
originNote: note,
167168
note: newNote
168169
})
169-
hashHistory.replace({
170+
history.replace({
170171
pathname: location.pathname,
171-
query: {
172+
search: queryString.stringify({
172173
key: newNote.key
173-
}
174+
})
174175
})
175176
this.setState({
176177
isMovingNote: false
@@ -814,7 +815,7 @@ class SnippetNoteDetail extends React.Component {
814815
<InfoPanel
815816
storageName={currentOption.storage.name}
816817
folderName={currentOption.folder.name}
817-
noteLink={`[${note.title}](:note:${location.query.key})`}
818+
noteLink={`[${note.title}](:note:${queryString.parse(location.search).key})`}
818819
updatedAt={formatDate(note.updatedAt)}
819820
createdAt={formatDate(note.createdAt)}
820821
exportAsMd={this.showWarning}

browser/main/Detail/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import StatusBar from '../StatusBar'
1010
import i18n from 'browser/lib/i18n'
1111
import debounceRender from 'react-debounce-render'
1212
import searchFromNotes from 'browser/lib/search'
13+
import queryString from 'query-string'
1314

1415
const OSX = global.process.platform === 'darwin'
1516

@@ -36,11 +37,11 @@ class Detail extends React.Component {
3637
}
3738

3839
render () {
39-
const { location, data, params, config } = this.props
40+
const { location, data, match: { params }, config } = this.props
41+
const noteKey = location.search !== '' && queryString.parse(location.search).key
4042
let note = null
4143

42-
if (location.query.key != null) {
43-
const noteKey = location.query.key
44+
if (location.search !== '') {
4445
const allNotes = data.noteMap.map(note => note)
4546
const trashedNotes = data.trashedSet.toJS().map(uniqueKey => data.noteMap.get(uniqueKey))
4647
let displayedNotes = allNotes

browser/main/Main.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import _ from 'lodash'
1212
import ConfigManager from 'browser/main/lib/ConfigManager'
1313
import mobileAnalytics from 'browser/main/lib/AwsMobileAnalyticsConfig'
1414
import eventEmitter from 'browser/main/lib/eventEmitter'
15-
import { hashHistory } from 'react-router'
16-
import store from 'browser/main/store'
15+
// import { hashHistory } from 'react-router'
16+
import { store, history } from 'browser/main/store'
1717
import i18n from 'browser/lib/i18n'
1818
import { getLocales } from 'browser/lib/Languages'
1919
import applyShortcuts from 'browser/main/lib/shortcutManager'
@@ -132,7 +132,7 @@ class Main extends React.Component {
132132
.then(() => data.storage)
133133
})
134134
.then(storage => {
135-
hashHistory.push('/storages/' + storage.key)
135+
history.push('/storages/' + storage.key)
136136
})
137137
.catch(err => {
138138
throw err
@@ -311,7 +311,7 @@ class Main extends React.Component {
311311
onMouseUp={e => this.handleMouseUp(e)}
312312
>
313313
<SideNav
314-
{..._.pick(this.props, ['dispatch', 'data', 'config', 'params', 'location'])}
314+
{..._.pick(this.props, ['dispatch', 'data', 'config', 'match', 'location'])}
315315
width={this.state.navWidth}
316316
/>
317317
{!config.isSideNavFolded &&
@@ -341,7 +341,7 @@ class Main extends React.Component {
341341
'dispatch',
342342
'config',
343343
'data',
344-
'params',
344+
'match',
345345
'location'
346346
])}
347347
/>
@@ -351,7 +351,7 @@ class Main extends React.Component {
351351
'dispatch',
352352
'data',
353353
'config',
354-
'params',
354+
'match',
355355
'location'
356356
])}
357357
/>
@@ -373,7 +373,7 @@ class Main extends React.Component {
373373
'dispatch',
374374
'data',
375375
'config',
376-
'params',
376+
'match',
377377
'location'
378378
])}
379379
ignorePreviewPointerEvents={this.state.isRightSliderFocused}

browser/main/NewNoteButton/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class NewNoteButton extends React.Component {
2121
this.state = {
2222
}
2323

24+
this.handleNewNoteButtonClick = this.handleNewNoteButtonClick.bind(this)
25+
26+
// why is there a newNoteHandler?!
2427
this.newNoteHandler = () => {
2528
this.handleNewNoteButtonClick()
2629
}
@@ -35,9 +38,8 @@ class NewNoteButton extends React.Component {
3538
}
3639

3740
handleNewNoteButtonClick (e) {
38-
const { location, params, dispatch, config } = this.props
41+
const { location, dispatch, match: { params }, config } = this.props
3942
const { storage, folder } = this.resolveTargetFolder()
40-
4143
if (config.ui.defaultNote === 'MARKDOWN_NOTE') {
4244
createMarkdownNote(storage.key, folder.key, dispatch, location, params, config)
4345
} else if (config.ui.defaultNote === 'SNIPPET_NOTE') {
@@ -55,9 +57,8 @@ class NewNoteButton extends React.Component {
5557
}
5658

5759
resolveTargetFolder () {
58-
const { data, params } = this.props
60+
const { data, match: { params } } = this.props
5961
let storage = data.storageMap.get(params.storageKey)
60-
6162
// Find first storage
6263
if (storage == null) {
6364
for (const kv of data.storageMap) {
@@ -93,7 +94,7 @@ class NewNoteButton extends React.Component {
9394
>
9495
<div styleName='control'>
9596
<button styleName='control-newNoteButton'
96-
onClick={(e) => this.handleNewNoteButtonClick(e)}>
97+
onClick={this.handleNewNoteButtonClick}>
9798
<img styleName='iconTag' src='../resources/icon/icon-newnote.svg' />
9899
<span styleName='control-newNoteButton-tooltip'>
99100
{i18n.__('Make a note')} {OSX ? '⌘' : i18n.__('Ctrl')} + N

0 commit comments

Comments
 (0)