mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:02:35 +08:00
37 lines
987 B
Text
37 lines
987 B
Text
|
React = require 'react'
|
||
|
ThreadListStore = require './thread-list-store'
|
||
|
{timestamp} = require './formatting-utils'
|
||
|
|
||
|
|
||
|
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) ->
|
||
|
idx = Math.floor(ThreadListStore.view().count() / @props.totalHeight * @props.viewportCenter)
|
||
|
@setState
|
||
|
idx: idx
|
||
|
item: ThreadListStore.view().get(idx)
|
||
|
|
||
|
render: ->
|
||
|
if @state.item
|
||
|
content = timestamp(@state.item.lastMessageReceivedTimestamp)
|
||
|
else
|
||
|
content = "Loading..."
|
||
|
<div className="scroll-tooltip">
|
||
|
{content}
|
||
|
</div>
|
||
|
|
||
|
module.exports = ThreadListScrollTooltip
|