1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

redirect when create new note

This commit is contained in:
Dick Choi
2016-06-01 10:19:36 +09:00
parent c691af9712
commit 45212e7e14
2 changed files with 17 additions and 2 deletions

View File

@@ -65,12 +65,20 @@ class TopBar extends React.Component {
return repo.addNote(newNote)
})
.then((note) => {
let { dispatch } = this.props
let { dispatch, location } = this.props
let { router } = this.context
dispatch({
type: 'ADD_NOTE',
repository: repositoryKey,
note: note
})
router.push({
pathname: location.pathname,
query: {
key: `${note._repository.key}-${note.key}`
}
})
})
.catch((err) => {
console.error(err)
@@ -139,6 +147,12 @@ class TopBar extends React.Component {
}
}
TopBar.contextTypes = {
router: PropTypes.shape({
push: PropTypes.func
})
}
TopBar.propTypes = {
dispatch: PropTypes.func,
config: PropTypes.shape({