mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 07:36:12 +08:00
fix(search): Don't show loading dots forever if requests fail
This commit is contained in:
parent
78665c5fec
commit
e6a4718a44
1 changed files with 12 additions and 5 deletions
|
@ -32,6 +32,13 @@ class SearchSubscription extends MutableQuerySubscription
|
|||
resultCount = 0
|
||||
resultIds = []
|
||||
|
||||
resultReturned = =>
|
||||
# Don't emit a "result" until we have at least one thread to display.
|
||||
# Otherwise it will show "No Results Found"
|
||||
if resultIds.length > 0 or resultCount is @_accountIds.length
|
||||
query = DatabaseStore.findAll(Thread).where(id: resultIds).order(Thread.attributes.lastMessageReceivedTimestamp.descending())
|
||||
@replaceQuery(query)
|
||||
|
||||
@_accountIds.forEach (aid) =>
|
||||
NylasAPI.makeRequest
|
||||
method: 'GET'
|
||||
|
@ -39,15 +46,15 @@ class SearchSubscription extends MutableQuerySubscription
|
|||
accountId: aid
|
||||
json: true
|
||||
returnsModel: true
|
||||
|
||||
.then (threads) =>
|
||||
return unless @_termsVersion is termsVersion
|
||||
resultCount += 1
|
||||
resultIds = resultIds.concat _.pluck(threads, 'id')
|
||||
resultReturned()
|
||||
|
||||
# Don't emit a "result" until we have at least one thread to display.
|
||||
# Otherwise it will show "No Results Found"
|
||||
if resultIds.length > 0 or resultCount is @_accountIds.length
|
||||
query = DatabaseStore.findAll(Thread).where(id: resultIds).order(Thread.attributes.lastMessageReceivedTimestamp.descending())
|
||||
@replaceQuery(query)
|
||||
.catch (err) =>
|
||||
resultCount += 1
|
||||
resultReturned()
|
||||
|
||||
module.exports = SearchSubscription
|
||||
|
|
Loading…
Reference in a new issue