fix(thread-list): Add more shouldComponentUpdate to prevent threadlist re-rendering as you move keyboard cursor

This commit is contained in:
Ben Gotow 2015-08-03 14:09:29 -07:00
parent b7e314ac62
commit 869331d799
3 changed files with 14 additions and 0 deletions

View file

@ -82,6 +82,12 @@ class EmptyState extends React.Component
@_unlisteners.push NamespaceStore.listen(@_onNamespacesChanged, @)
@_onNamespacesChanged()
shouldComponentUpdate: (nextProps, nextState) ->
# Avoid deep comparison of dataView, which is a very complex object
return true if nextProps.visible isnt @props.visible
return true if nextProps.dataView isnt @props.dataView
return not _.isEqual(nextState, @state)
_onNamespacesChanged: ->
namespace = NamespaceStore.current()
@_worker = NylasAPI.workerForNamespace(namespace)

View file

@ -39,6 +39,10 @@ class ThreadListIcon extends React.Component
msgs = _.filter msgs, (m) -> m.isSaved() and not m.draft
return msgs
shouldComponentUpdate: (nextProps) =>
return false if nextProps.thread is @props.thread
true
render: =>
<div className="thread-icon #{@_iconType()}" onClick={@_onToggleStar}></div>

View file

@ -8,6 +8,10 @@ class ThreadListParticipants extends React.Component
@propTypes:
thread: React.PropTypes.object.isRequired
shouldComponentUpdate: (nextProps) =>
return false if nextProps.thread is @props.thread
true
render: =>
items = @getParticipants()