mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 08:16:09 +08:00
fix(message): Re-write nasty code in participants()
This commit is contained in:
parent
8fb062f765
commit
476431bcb1
|
@ -222,12 +222,15 @@ class Message extends ModelWithMetadata
|
|||
# Public: Returns a set of uniqued message participants by combining the
|
||||
# `to`, `cc`, and `from` fields.
|
||||
participants: ->
|
||||
participants = {}
|
||||
contacts = _.union((@to ? []), (@cc ? []), (@from ? []))
|
||||
for contact in contacts
|
||||
if contact? and contact.email?.length > 0
|
||||
participants["#{(contact?.email ? "").toLowerCase().trim()} #{(contact?.name ? "").toLowerCase().trim()}"] = contact if contact?
|
||||
return _.values(participants)
|
||||
seen = {}
|
||||
all = []
|
||||
for contact in [].concat(@to, @cc, @from)
|
||||
continue unless contact.email
|
||||
key = contact.toString().trim().toLowerCase()
|
||||
continue if seen[key]
|
||||
seen[key] = true
|
||||
all.push(contact)
|
||||
all
|
||||
|
||||
# Public: Returns a hash with `to` and `cc` keys for authoring a new draft in
|
||||
# "reply all" to this message. This method takes into account whether the
|
||||
|
|
Loading…
Reference in a new issue