2016-01-15 06:04:51 +08:00
|
|
|
React = require 'react'
|
2016-07-29 08:42:14 +08:00
|
|
|
{Utils, DateUtils} = 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
|
2016-07-29 08:42:14 +08:00
|
|
|
content = DateUtils.shortTimeString(@state.item.lastMessageReceivedTimestamp)
|
2016-01-15 06:04:51 +08:00
|
|
|
else
|
|
|
|
content = "Loading..."
|
|
|
|
<div className="scroll-tooltip">
|
|
|
|
{content}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
module.exports = ThreadListScrollTooltip
|