mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 02:36:36 +00:00
Fix file list blinking on search
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import CSSModules from 'browser/lib/CSSModules'
|
import CSSModules from 'browser/lib/CSSModules'
|
||||||
|
import debounceRender from 'react-debounce-render'
|
||||||
import styles from './NoteList.styl'
|
import styles from './NoteList.styl'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
@@ -947,16 +948,24 @@ class NoteList extends React.Component {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const viewType = this.getViewType()
|
const viewType = this.getViewType()
|
||||||
|
|
||||||
|
const autoSelectFirst = notes.length === 1
|
||||||
|
|| selectedNoteKeys.length === 0
|
||||||
|
|| notes.every( note => !selectedNoteKeys.includes(note.key))
|
||||||
|
|
||||||
const noteList = notes
|
const noteList = notes
|
||||||
.map(note => {
|
.map( (note, index) => {
|
||||||
if (note == null) {
|
if (note == null) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const isDefault = config.listStyle === 'DEFAULT'
|
const isDefault = config.listStyle === 'DEFAULT'
|
||||||
const uniqueKey = getNoteKey(note)
|
const uniqueKey = getNoteKey(note)
|
||||||
const isActive = selectedNoteKeys.includes(uniqueKey)
|
|
||||||
|
const isActive =
|
||||||
|
selectedNoteKeys.includes(uniqueKey)
|
||||||
|
|| notes.length === 1
|
||||||
|
|| (autoSelectFirst && index === 0)
|
||||||
const dateDisplay = moment(
|
const dateDisplay = moment(
|
||||||
config.sortBy === 'CREATED_AT'
|
config.sortBy === 'CREATED_AT'
|
||||||
? note.createdAt : note.updatedAt
|
? note.createdAt : note.updatedAt
|
||||||
@@ -1058,4 +1067,4 @@ NoteList.propTypes = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(NoteList, styles)
|
export default debounceRender(CSSModules(NoteList, styles))
|
||||||
|
|||||||
@@ -89,6 +89,7 @@
|
|||||||
"raphael": "^2.2.7",
|
"raphael": "^2.2.7",
|
||||||
"react": "^15.5.4",
|
"react": "^15.5.4",
|
||||||
"react-codemirror": "^0.3.0",
|
"react-codemirror": "^0.3.0",
|
||||||
|
"react-debounce-render": "^4.0.1",
|
||||||
"react-dom": "^15.0.2",
|
"react-dom": "^15.0.2",
|
||||||
"react-redux": "^4.4.5",
|
"react-redux": "^4.4.5",
|
||||||
"react-sortable-hoc": "^0.6.7",
|
"react-sortable-hoc": "^0.6.7",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
"@ava/babel-plugin-throws-helper@^2.0.0":
|
"@ava/babel-plugin-throws-helper@^2.0.0":
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@ava/babel-plugin-throws-helper/-/babel-plugin-throws-helper-2.0.0.tgz#2fc1fe3c211a71071a4eca7b8f7af5842cd1ae7c"
|
resolved "https://registry.yarnpkg.com/@ava/babel-plugin-throws-helper/-/babel-plugin-throws-helper-2.0.0.tgz#2fc1fe3c211a71071a4eca7b8f7af5842cd1ae7c"
|
||||||
@@ -6891,6 +6892,12 @@ react-css-modules@^3.7.6:
|
|||||||
lodash "^4.6.1"
|
lodash "^4.6.1"
|
||||||
object-unfreeze "^1.0.2"
|
object-unfreeze "^1.0.2"
|
||||||
|
|
||||||
|
react-debounce-render@^4.0.1:
|
||||||
|
version "4.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-debounce-render/-/react-debounce-render-4.0.1.tgz#3a1814f67eca17e91d3101799805a7a4e2128a84"
|
||||||
|
dependencies:
|
||||||
|
lodash "^4.17.4"
|
||||||
|
|
||||||
react-deep-force-update@^1.0.0:
|
react-deep-force-update@^1.0.0:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.1.1.tgz#bcd31478027b64b3339f108921ab520b4313dc2c"
|
resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.1.1.tgz#bcd31478027b64b3339f108921ab520b4313dc2c"
|
||||||
|
|||||||
Reference in New Issue
Block a user