Skip to content

Commit 6510152

Browse files
author
Martin Price
committed
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
1 parent 671dff0 commit 6510152

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

browser/main/NoteList/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,15 @@ class NoteList extends React.Component {
170170
}
171171
}
172172

173-
focusNote (selectedNoteKeys, noteKey) {
173+
focusNote (selectedNoteKeys, noteKey, pathname) {
174174
const { router } = this.context
175-
const { location } = this.props
176175

177176
this.setState({
178177
selectedNoteKeys
179178
})
180179

181180
router.push({
182-
pathname: location.pathname,
181+
pathname,
183182
query: {
184183
key: noteKey
185184
}
@@ -198,6 +197,7 @@ class NoteList extends React.Component {
198197
}
199198
let { selectedNoteKeys } = this.state
200199
const { shiftKeyDown } = this.state
200+
const { location } = this.props
201201

202202
let targetIndex = this.getTargetIndex()
203203

@@ -214,7 +214,7 @@ class NoteList extends React.Component {
214214
selectedNoteKeys.push(priorNoteKey)
215215
}
216216

217-
this.focusNote(selectedNoteKeys, priorNoteKey)
217+
this.focusNote(selectedNoteKeys, priorNoteKey, location.pathname)
218218

219219
ee.emit('list:moved')
220220
}
@@ -225,6 +225,7 @@ class NoteList extends React.Component {
225225
}
226226
let { selectedNoteKeys } = this.state
227227
const { shiftKeyDown } = this.state
228+
const { location } = this.props
228229

229230
let targetIndex = this.getTargetIndex()
230231
const isTargetLastNote = targetIndex === this.notes.length - 1
@@ -247,7 +248,7 @@ class NoteList extends React.Component {
247248
selectedNoteKeys.push(nextNoteKey)
248249
}
249250

250-
this.focusNote(selectedNoteKeys, nextNoteKey)
251+
this.focusNote(selectedNoteKeys, nextNoteKey, location.pathname)
251252

252253
ee.emit('list:moved')
253254
}
@@ -259,7 +260,7 @@ class NoteList extends React.Component {
259260
}
260261

261262
const selectedNoteKeys = [noteHash]
262-
this.focusNote(selectedNoteKeys, noteHash)
263+
this.focusNote(selectedNoteKeys, noteHash, '/home')
263264

264265
ee.emit('list:moved')
265266
}

0 commit comments

Comments
 (0)