Skip to content

Commit 3c39dc3

Browse files
AWolf81Rokt33r
authored andcommitted
change redirecting to connected-react-router
1 parent 7e8f46c commit 3c39dc3

File tree

6 files changed

+24
-25
lines changed

6 files changed

+24
-25
lines changed

browser/lib/newNote.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { history } from 'browser/main/store'
21
import dataApi from 'browser/main/lib/dataApi'
32
import ee from 'browser/main/lib/eventEmitter'
43
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
54
import queryString from 'query-string'
5+
import { push } from 'connected-react-router'
66

77
export function createMarkdownNote (storage, folder, dispatch, location, params, config) {
88
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
@@ -29,10 +29,10 @@ export function createMarkdownNote (storage, folder, dispatch, location, params,
2929
note: note
3030
})
3131

32-
history.push({
32+
dispatch(push({
3333
pathname: location.pathname,
3434
search: queryString.stringify({ key: noteHash })
35-
})
35+
}))
3636
ee.emit('list:jump', noteHash)
3737
ee.emit('detail:focus')
3838
})
@@ -71,10 +71,10 @@ export function createSnippetNote (storage, folder, dispatch, location, params,
7171
type: 'UPDATE_NOTE',
7272
note: note
7373
})
74-
history.push({
74+
dispatch(push({
7575
pathname: location.pathname,
7676
search: queryString.stringify({ key: noteHash })
77-
})
77+
}))
7878
ee.emit('list:jump', noteHash)
7979
ee.emit('detail:focus')
8080
})

browser/main/Detail/MarkdownNoteDetail.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import StarButton from './StarButton'
99
import TagSelect from './TagSelect'
1010
import FolderSelect from './FolderSelect'
1111
import dataApi from 'browser/main/lib/dataApi'
12-
import { history } from 'browser/main/store'
1312
import ee from 'browser/main/lib/eventEmitter'
1413
import markdown from 'browser/lib/markdownTextHelper'
1514
import StatusBar from '../StatusBar'
@@ -31,6 +30,7 @@ import striptags from 'striptags'
3130
import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote'
3231
import markdownToc from 'browser/lib/markdown-toc-generator'
3332
import queryString from 'query-string'
33+
import { replace } from 'connected-react-router'
3434

3535
class MarkdownNoteDetail extends React.Component {
3636
constructor (props) {
@@ -141,6 +141,7 @@ class MarkdownNoteDetail extends React.Component {
141141
}
142142

143143
handleFolderChange (e) {
144+
const { dispatch } = this.props
144145
const { note } = this.state
145146
const value = this.refs.folder.value
146147
const splitted = value.split('-')
@@ -160,12 +161,12 @@ class MarkdownNoteDetail extends React.Component {
160161
originNote: note,
161162
note: newNote
162163
})
163-
history.replace({
164+
dispatch(replace({
164165
pathname: location.pathname,
165166
search: queryString.stringify({
166167
key: newNote.key
167168
})
168-
})
169+
}))
169170
this.setState({
170171
isMovingNote: false
171172
})

browser/main/Detail/SnippetNoteDetail.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import StarButton from './StarButton'
88
import TagSelect from './TagSelect'
99
import FolderSelect from './FolderSelect'
1010
import dataApi from 'browser/main/lib/dataApi'
11-
import { history } from 'browser/main/store'
1211
import ee from 'browser/main/lib/eventEmitter'
1312
import CodeMirror from 'codemirror'
1413
import 'codemirror-mode-elixir'
@@ -31,6 +30,7 @@ import i18n from 'browser/lib/i18n'
3130
import { confirmDeleteNote } from 'browser/lib/confirmDeleteNote'
3231
import markdownToc from 'browser/lib/markdown-toc-generator'
3332
import queryString from 'query-string'
33+
import { replace } from 'connected-react-router'
3434

3535
const electron = require('electron')
3636
const { remote } = electron
@@ -166,12 +166,12 @@ class SnippetNoteDetail extends React.Component {
166166
originNote: note,
167167
note: newNote
168168
})
169-
history.replace({
169+
dispatch(replace({
170170
pathname: location.pathname,
171171
search: queryString.stringify({
172172
key: newNote.key
173173
})
174-
})
174+
}))
175175
this.setState({
176176
isMovingNote: false
177177
})

browser/main/Main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ 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 { store, history } from 'browser/main/store'
15+
import { store } from 'browser/main/store'
1616
import i18n from 'browser/lib/i18n'
1717
import { getLocales } from 'browser/lib/Languages'
1818
import applyShortcuts from 'browser/main/lib/shortcutManager'
19+
import { push } from 'connected-react-router'
1920
const path = require('path')
2021
const electron = require('electron')
2122
const { remote } = electron
@@ -131,7 +132,7 @@ class Main extends React.Component {
131132
.then(() => data.storage)
132133
})
133134
.then(storage => {
134-
history.push('/storages/' + storage.key)
135+
store.dispatch(push('/storages/' + storage.key))
135136
})
136137
.catch(err => {
137138
throw err

browser/main/NoteList/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import NoteItemSimple from 'browser/components/NoteItemSimple'
1414
import searchFromNotes from 'browser/lib/search'
1515
import fs from 'fs'
1616
import path from 'path'
17-
import { history } from 'browser/main/store'
1817
import { push, replace } from 'connected-react-router'
1918
import copy from 'copy-to-clipboard'
2019
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
@@ -764,10 +763,10 @@ class NoteList extends React.Component {
764763
selectedNoteKeys: [note.key]
765764
})
766765

767-
history.push({
766+
dispatch(push({
768767
pathname: location.pathname,
769768
search: queryString.stringify({key: note.key})
770-
})
769+
}))
771770
})
772771
}
773772

@@ -776,9 +775,7 @@ class NoteList extends React.Component {
776775
return copy(noteLink)
777776
}
778777

779-
// Navigate seems unused
780778
navigate (sender, pathname) {
781-
// const { router } = this.context
782779
const { dispatch } = this.props
783780
dispatch(push({
784781
pathname,
@@ -949,10 +946,10 @@ class NoteList extends React.Component {
949946
type: 'UPDATE_NOTE',
950947
note: note
951948
})
952-
history.push({
949+
dispatch(push({
953950
pathname: location.pathname,
954951
search: queryString.stringify({key: getNoteKey(note)})
955-
})
952+
}))
956953
})
957954
})
958955
})

browser/main/SideNav/StorageItem.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import PropTypes from 'prop-types'
22
import React from 'react'
33
import CSSModules from 'browser/lib/CSSModules'
44
import styles from './StorageItem.styl'
5-
import { history } from 'browser/main/store'
65
import modal from 'browser/main/lib/modal'
76
import CreateFolderModal from 'browser/main/modals/CreateFolderModal'
87
import RenameFolderModal from 'browser/main/modals/RenameFolderModal'
@@ -12,6 +11,7 @@ import _ from 'lodash'
1211
import { SortableElement } from 'react-sortable-hoc'
1312
import i18n from 'browser/lib/i18n'
1413
import context from 'browser/lib/context'
14+
import { push } from 'connected-react-router'
1515

1616
const { remote } = require('electron')
1717
const { dialog } = remote
@@ -134,14 +134,14 @@ class StorageItem extends React.Component {
134134
}
135135

136136
handleHeaderInfoClick (e) {
137-
const { storage } = this.props
138-
history.push('/storages/' + storage.key)
137+
const { storage, dispatch } = this.props
138+
dispatch(push('/storages/' + storage.key))
139139
}
140140

141141
handleFolderButtonClick (folderKey) {
142142
return (e) => {
143-
const { storage } = this.props
144-
history.push('/storages/' + storage.key + '/folders/' + folderKey)
143+
const { storage, dispatch } = this.props
144+
dispatch(push('/storages/' + storage.key + '/folders/' + folderKey))
145145
}
146146
}
147147

0 commit comments

Comments
 (0)