Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions browser/main/NoteList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class NoteList extends React.Component {
}
let { router } = this.context
let { location } = this.props
let { selectedNoteKeys } = this.state
let { selectedNoteKeys, shiftKeyDown } = this.state

let targetIndex = this.getTargetIndex()

Expand All @@ -162,10 +162,16 @@ class NoteList extends React.Component {
}
targetIndex--

selectedNoteKeys = []
if (!shiftKeyDown) {
selectedNoteKeys = []
}
const priorNote = Object.assign({}, this.notes[targetIndex])
const priorNoteKey = `${priorNote.storage}-${priorNote.key}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use getNoteKey for creating note key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used that. Thanks.

selectedNoteKeys.push(priorNoteKey)
if (selectedNoteKeys.includes(priorNoteKey)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use findNoteByKey to check that note key exists in array or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sota1235
No, It findNoteByKeyis only for find note not keys.

Currently I have state that only save selectedNoteKeys not notes

selectedNoteKeys.pop()
} else {
selectedNoteKeys.push(priorNoteKey)
}

this.focusNote(selectedNoteKeys, priorNoteKey)
}
Expand All @@ -176,22 +182,30 @@ class NoteList extends React.Component {
}
let { router } = this.context
let { location } = this.props
let { selectedNoteKeys } = this.state
let { selectedNoteKeys, shiftKeyDown } = this.state

let targetIndex = this.getTargetIndex()

if (targetIndex === this.notes.length - 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add && shiftKeyDown

return
} else if (targetIndex === this.notes.length - 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some variables to keep value of targetIndex === this.notes.length - 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added variable. Thank you!

targetIndex = 0
} else {
targetIndex++
if (targetIndex < 0) targetIndex = 0
else if (targetIndex > this.notes.length - 1) targetIndex === this.notes.length - 1
}

selectedNoteKeys = []
if (!shiftKeyDown) {
selectedNoteKeys = []
}
const nextNote = Object.assign({}, this.notes[targetIndex])
const nextNoteKey = `${nextNote.storage}-${nextNote.key}`
selectedNoteKeys.push(nextNoteKey)
if (selectedNoteKeys.includes(nextNoteKey)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just mentioned it above.

selectedNoteKeys.pop()
} else {
selectedNoteKeys.push(nextNoteKey)
}

this.focusNote(selectedNoteKeys, nextNoteKey)

Expand Down Expand Up @@ -222,6 +236,7 @@ class NoteList extends React.Component {
}

handleNoteListKeyDown (e) {
const { shiftKeyDown } = this.state
if (e.metaKey || e.ctrlKey) return true

if (e.keyCode === 65 && !e.shiftKey) {
Expand All @@ -231,7 +246,7 @@ class NoteList extends React.Component {

if (e.keyCode === 68) {
e.preventDefault()
ee.emit('detail:delete')
this.deleteNote()
}

if (e.keyCode === 69) {
Expand Down