Mailspring/internal_packages/thread-list/lib/thread-list-scroll-tooltip.cjsx

36 lines
1,001 B
Text
Raw Normal View History

2016-01-15 06:04:51 +08:00
React = require 'react'
{Utils} = require 'nylas-exports'
2016-01-15 06:04:51 +08:00
ThreadListStore = require './thread-list-store'
class ThreadListScrollTooltip extends React.Component
@displayName: 'ThreadListScrollTooltip'
@propTypes:
viewportCenter: React.PropTypes.number.isRequired
totalHeight: React.PropTypes.number.isRequired
componentWillMount: =>
@setupForProps(@props)
componentWillReceiveProps: (newProps) =>
@setupForProps(newProps)
shouldComponentUpdate: (newProps, newState) =>
@state?.idx isnt newState.idx
setupForProps: (props) ->
2016-01-15 07:04:17 +08:00
idx = Math.floor(ThreadListStore.dataSource().count() / @props.totalHeight * @props.viewportCenter)
2016-01-15 06:04:51 +08:00
@setState
idx: idx
2016-01-15 07:04:17 +08:00
item: ThreadListStore.dataSource().get(idx)
2016-01-15 06:04:51 +08:00
render: ->
if @state.item
content = Utils.shortTimeString(@state.item.lastMessageReceivedTimestamp)
2016-01-15 06:04:51 +08:00
else
content = "Loading..."
<div className="scroll-tooltip">
{content}
</div>
module.exports = ThreadListScrollTooltip