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