{Actions, React} = require 'nylas-exports' {RetinaImg} = require 'nylas-component-kit' class StreamingSyncActivity extends React.Component constructor: (@props) -> @_timeoutId = null @state = receivingDelta: false componentDidMount: => @_unlistener = Actions.longPollReceivedRawDeltasPing.listen(@_onDeltaReceived) componentWillUnmount: => @_unlistener() if @_unlistener clearTimeout(@_timeoutId) if @_timeoutId render: => return false unless @state.receivingDelta
Syncing your mailbox…
_onDeltaReceived: (countDeltas) => tooSmallForNotification = countDeltas <= 10 return if tooSmallForNotification if @_timeoutId clearTimeout(@_timeoutId) @_timeoutId = setTimeout(( => delete(@_timeoutId) @setState(receivingDelta: false) ), 20000) @setState(receivingDelta: true) module.exports = StreamingSyncActivity