mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 10:12:00 +08:00
fix(contacts): Bound the size of the ranked contact cache
This commit is contained in:
parent
422d5f8d8f
commit
e4727f0562
1 changed files with 6 additions and 0 deletions
|
@ -151,6 +151,12 @@ class ContactStore extends NylasStore
|
|||
@_rankedContacts = []
|
||||
return
|
||||
|
||||
# Sort the emails by rank and then clip to 400 so that our ranked cache
|
||||
# has a bounded size.
|
||||
emails = _.sortBy emails, (email) ->
|
||||
(- (rankings[email.toLowerCase()] ? 0) / 1)
|
||||
emails.length = 400 if emails.length > 400
|
||||
|
||||
DatabaseStore.findAll(Contact, {email: emails}).then (contacts) =>
|
||||
contacts = @_distinctByEmail(contacts)
|
||||
for contact in contacts
|
||||
|
|
Loading…
Reference in a new issue