Skip to content

Commit aa56aad

Browse files
committed
Improvement on the code
The improvement was suggested by github
1 parent ad7b155 commit aa56aad

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

browser/main/NoteList/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,14 @@ class NoteList extends React.Component {
427427
selectedNoteKeys.push(uniqueKey)
428428

429429
if (shiftKeyDown && hasSelectedNoteKey) {
430-
const firstSelectedNoteIndex =
431-
Math.max(this.getNoteIndexByKey(selectedNoteKeys[0]),
432-
this.state.firstShiftSelectedNoteIndex)
430+
const firstSelectedNoteIndex = selectedNoteKeys[0] > this.state.firstShiftSelectedNoteIndex
431+
? selectedNoteKeys[0] : this.state.firstShiftSelectedNoteIndex
433432
const lastSelectedNoteIndex = this.getNoteIndexByKey(uniqueKey)
434-
const startIndex = Math.min(firstSelectedNoteIndex, lastSelectedNoteIndex)
435-
const endIndex = Math.max(firstSelectedNoteIndex, lastSelectedNoteIndex)
433+
const startIndex = firstSelectedNoteIndex < lastSelectedNoteIndex
434+
? firstSelectedNoteIndex : lastSelectedNoteIndex
435+
const endIndex = firstSelectedNoteIndex > lastSelectedNoteIndex
436+
? firstSelectedNoteIndex : lastSelectedNoteIndex
437+
436438
selectedNoteKeys = []
437439
for (let i = startIndex; i <= endIndex; i++) {
438440
selectedNoteKeys.push(this.notes[i].key)

0 commit comments

Comments
 (0)