mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Fix the variable name to more appropriate one
This commit is contained in:
@@ -86,7 +86,7 @@ class NoteList extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
ctrlKeyDown: false,
|
ctrlKeyDown: false,
|
||||||
shiftKeyDown: false,
|
shiftKeyDown: false,
|
||||||
firstShiftSelectedNoteIndex: -1,
|
prevShiftNoteIndex: -1,
|
||||||
selectedNoteKeys: []
|
selectedNoteKeys: []
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,9 +409,8 @@ class NoteList extends React.Component {
|
|||||||
handleNoteClick (e, uniqueKey) {
|
handleNoteClick (e, uniqueKey) {
|
||||||
const { router } = this.context
|
const { router } = this.context
|
||||||
const { location } = this.props
|
const { location } = this.props
|
||||||
let { selectedNoteKeys } = this.state
|
let { selectedNoteKeys, prevShiftNoteIndex } = this.state
|
||||||
const { ctrlKeyDown, shiftKeyDown } = this.state
|
const { ctrlKeyDown, shiftKeyDown } = this.state
|
||||||
let firstShiftSelectedNoteIndex = -1
|
|
||||||
const hasSelectedNoteKey = selectedNoteKeys.length > 0
|
const hasSelectedNoteKey = selectedNoteKeys.length > 0
|
||||||
|
|
||||||
if (ctrlKeyDown && selectedNoteKeys.includes(uniqueKey)) {
|
if (ctrlKeyDown && selectedNoteKeys.includes(uniqueKey)) {
|
||||||
@@ -424,28 +423,40 @@ class NoteList extends React.Component {
|
|||||||
if (!ctrlKeyDown && !shiftKeyDown) {
|
if (!ctrlKeyDown && !shiftKeyDown) {
|
||||||
selectedNoteKeys = []
|
selectedNoteKeys = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!shiftKeyDown) {
|
||||||
|
prevShiftNoteIndex = -1
|
||||||
|
}
|
||||||
|
|
||||||
selectedNoteKeys.push(uniqueKey)
|
selectedNoteKeys.push(uniqueKey)
|
||||||
|
|
||||||
if (shiftKeyDown && hasSelectedNoteKey) {
|
if (shiftKeyDown && hasSelectedNoteKey) {
|
||||||
const firstSelectedNoteIndex = selectedNoteKeys[0] > this.state.firstShiftSelectedNoteIndex
|
let firstShiftNoteIndex = this.getNoteIndexByKey(selectedNoteKeys[0])
|
||||||
? selectedNoteKeys[0] : this.state.firstShiftSelectedNoteIndex
|
// Shift selection can either start from first note in the exisiting selectedNoteKeys
|
||||||
const lastSelectedNoteIndex = this.getNoteIndexByKey(uniqueKey)
|
// or previous first shift note index
|
||||||
const startIndex = firstSelectedNoteIndex < lastSelectedNoteIndex
|
firstShiftNoteIndex = firstShiftNoteIndex > prevShiftNoteIndex
|
||||||
? firstSelectedNoteIndex : lastSelectedNoteIndex
|
? firstShiftNoteIndex : prevShiftNoteIndex
|
||||||
const endIndex = firstSelectedNoteIndex > lastSelectedNoteIndex
|
|
||||||
? firstSelectedNoteIndex : lastSelectedNoteIndex
|
const lastShiftNoteIndex = this.getNoteIndexByKey(uniqueKey)
|
||||||
|
|
||||||
|
const startIndex = firstShiftNoteIndex < lastShiftNoteIndex
|
||||||
|
? firstShiftNoteIndex : lastShiftNoteIndex
|
||||||
|
const endIndex = firstShiftNoteIndex > lastShiftNoteIndex
|
||||||
|
? firstShiftNoteIndex : lastShiftNoteIndex
|
||||||
|
|
||||||
selectedNoteKeys = []
|
selectedNoteKeys = []
|
||||||
for (let i = startIndex; i <= endIndex; i++) {
|
for (let i = startIndex; i <= endIndex; i++) {
|
||||||
selectedNoteKeys.push(this.notes[i].key)
|
selectedNoteKeys.push(this.notes[i].key)
|
||||||
}
|
}
|
||||||
|
|
||||||
firstShiftSelectedNoteIndex = firstSelectedNoteIndex
|
if (prevShiftNoteIndex < 0) {
|
||||||
|
prevShiftNoteIndex = firstShiftNoteIndex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedNoteKeys,
|
selectedNoteKeys,
|
||||||
firstShiftSelectedNoteIndex
|
prevShiftNoteIndex
|
||||||
})
|
})
|
||||||
|
|
||||||
router.push({
|
router.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user