mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-19 14:40:26 +08:00
fix(empty-state): Don't show empty state briefly when loading threads
This commit is contained in:
parent
a38d65cb2a
commit
421936b1c6
2 changed files with 8 additions and 4 deletions
|
@ -47,7 +47,7 @@ class ListTabular extends React.Component
|
|||
@_unlisten?()
|
||||
@_unlisten = dataSource.listen =>
|
||||
@setState(@buildStateForRange())
|
||||
@setState(@buildStateForRange(dataSource: dataSource))
|
||||
@setState(@buildStateForRange(start: -1, end: -1, dataSource: dataSource))
|
||||
|
||||
buildStateForRange: ({dataSource, start, end} = {}) =>
|
||||
start ?= @state.renderedRangeStart
|
||||
|
|
|
@ -11,13 +11,16 @@ go away!
|
|||
###
|
||||
class ObservableListDataSource extends ListTabular.DataSource
|
||||
|
||||
constructor: ($resultSetObservable, @_setRetainedRange) ->
|
||||
constructor: (@$resultSetObservable, @_setRetainedRange) ->
|
||||
super
|
||||
@_countEstimate = -1
|
||||
@_resultSet = null
|
||||
@_resultDesiredLast = null
|
||||
|
||||
@_subscription = $resultSetObservable.subscribe (nextResultSet) =>
|
||||
# Wait until a retained range is set before subscribing to result sets
|
||||
|
||||
_attach: =>
|
||||
@_subscription = @$resultSetObservable.subscribe (nextResultSet) =>
|
||||
if nextResultSet.range().end is @_resultDesiredLast
|
||||
@_countEstimate = Math.max(@_countEstimate, nextResultSet.range().end + 1)
|
||||
else
|
||||
|
@ -37,6 +40,7 @@ class ObservableListDataSource extends ListTabular.DataSource
|
|||
setRetainedRange: ({start, end}) ->
|
||||
@_resultDesiredLast = end
|
||||
@_setRetainedRange({start, end})
|
||||
@_attach() if not @_subscription
|
||||
|
||||
# Retrieving Data
|
||||
|
||||
|
@ -44,7 +48,7 @@ class ObservableListDataSource extends ListTabular.DataSource
|
|||
@_countEstimate
|
||||
|
||||
loaded: ->
|
||||
@_resultSet isnt null and @_resultDesiredLast > 0
|
||||
@_resultSet isnt null
|
||||
|
||||
empty: =>
|
||||
not @_resultSet or @_resultSet.empty()
|
||||
|
|
Loading…
Reference in a new issue