mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Always redirect to /home when jumping to a note by hash
The note which we are jumping to may not be available in the note list for a number of reasons (e.g. if there is an active search, or if another storage folder is selected, or if the note list is showing starred notes). This affects both when we are creating a new note (which may not match the current search criteria), and when jumping to a note via a link in another note (and the linked note may not be available for any of the above reasons). 2241
This commit is contained in:
@@ -170,16 +170,15 @@ class NoteList extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
focusNote (selectedNoteKeys, noteKey) {
|
focusNote (selectedNoteKeys, noteKey, pathname) {
|
||||||
const { router } = this.context
|
const { router } = this.context
|
||||||
const { location } = this.props
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedNoteKeys
|
selectedNoteKeys
|
||||||
})
|
})
|
||||||
|
|
||||||
router.push({
|
router.push({
|
||||||
pathname: location.pathname,
|
pathname,
|
||||||
query: {
|
query: {
|
||||||
key: noteKey
|
key: noteKey
|
||||||
}
|
}
|
||||||
@@ -198,6 +197,7 @@ class NoteList extends React.Component {
|
|||||||
}
|
}
|
||||||
let { selectedNoteKeys } = this.state
|
let { selectedNoteKeys } = this.state
|
||||||
const { shiftKeyDown } = this.state
|
const { shiftKeyDown } = this.state
|
||||||
|
const { location } = this.props
|
||||||
|
|
||||||
let targetIndex = this.getTargetIndex()
|
let targetIndex = this.getTargetIndex()
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ class NoteList extends React.Component {
|
|||||||
selectedNoteKeys.push(priorNoteKey)
|
selectedNoteKeys.push(priorNoteKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.focusNote(selectedNoteKeys, priorNoteKey)
|
this.focusNote(selectedNoteKeys, priorNoteKey, location.pathname)
|
||||||
|
|
||||||
ee.emit('list:moved')
|
ee.emit('list:moved')
|
||||||
}
|
}
|
||||||
@@ -225,6 +225,7 @@ class NoteList extends React.Component {
|
|||||||
}
|
}
|
||||||
let { selectedNoteKeys } = this.state
|
let { selectedNoteKeys } = this.state
|
||||||
const { shiftKeyDown } = this.state
|
const { shiftKeyDown } = this.state
|
||||||
|
const { location } = this.props
|
||||||
|
|
||||||
let targetIndex = this.getTargetIndex()
|
let targetIndex = this.getTargetIndex()
|
||||||
const isTargetLastNote = targetIndex === this.notes.length - 1
|
const isTargetLastNote = targetIndex === this.notes.length - 1
|
||||||
@@ -247,7 +248,7 @@ class NoteList extends React.Component {
|
|||||||
selectedNoteKeys.push(nextNoteKey)
|
selectedNoteKeys.push(nextNoteKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.focusNote(selectedNoteKeys, nextNoteKey)
|
this.focusNote(selectedNoteKeys, nextNoteKey, location.pathname)
|
||||||
|
|
||||||
ee.emit('list:moved')
|
ee.emit('list:moved')
|
||||||
}
|
}
|
||||||
@@ -259,7 +260,7 @@ class NoteList extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const selectedNoteKeys = [noteHash]
|
const selectedNoteKeys = [noteHash]
|
||||||
this.focusNote(selectedNoteKeys, noteHash)
|
this.focusNote(selectedNoteKeys, noteHash, '/home')
|
||||||
|
|
||||||
ee.emit('list:moved')
|
ee.emit('list:moved')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user