mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-12 07:34:52 +08:00
fix(participants): Remove all sorts of broken cruft, remove "Me"
This commit is contained in:
parent
453e449955
commit
4d6566327f
1 changed files with 7 additions and 43 deletions
|
@ -2,8 +2,6 @@
|
||||||
React = require "react"
|
React = require "react"
|
||||||
_ = require "underscore-plus"
|
_ = require "underscore-plus"
|
||||||
|
|
||||||
SORT = false
|
|
||||||
|
|
||||||
DefaultChip = React.createClass
|
DefaultChip = React.createClass
|
||||||
render: ->
|
render: ->
|
||||||
display = @props.participant.name? and @props.participant.name or @props.participant.email
|
display = @props.participant.name? and @props.participant.name or @props.participant.email
|
||||||
|
@ -35,51 +33,17 @@ module.exports = React.createClass
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
getParticipants: ->
|
getParticipants: ->
|
||||||
me = NamespaceStore.current().me()
|
myEmail = NamespaceStore.current().emailAddress
|
||||||
|
list = @props.participants
|
||||||
|
|
||||||
if SORT
|
# Remove 'Me' if there is more than one participant
|
||||||
sorted = _.sortBy @props.participants, (p) -> p.displayName()
|
if list.length > 1
|
||||||
else
|
list = _.reject list, (p) -> p.email is myEmail
|
||||||
sorted = @props.participants
|
|
||||||
|
|
||||||
# Pull 'me'
|
list.forEach (p) ->
|
||||||
user = _.findWhere sorted, me
|
|
||||||
if self
|
|
||||||
sorted = _.without sorted, user
|
|
||||||
|
|
||||||
# Push 'me' if we just emptied the list
|
|
||||||
if user? and sorted.length == 0
|
|
||||||
sorted.push me
|
|
||||||
# Unshift 'me' if context says we're the sender
|
|
||||||
else if @_fromUserUnrepliedContext()
|
|
||||||
sorted.unshift me
|
|
||||||
# Unshift 'me' if context says we're the sender and it's a group thread
|
|
||||||
else if @_fromUserGroupThreadContext()
|
|
||||||
sorted.unshift me
|
|
||||||
|
|
||||||
# Pull the sender to the front, if it's not 'me'
|
|
||||||
if @_getSender()? and @_getSender().email != me.email
|
|
||||||
# It's probably the same contact object but why risk the fuck up?
|
|
||||||
sender = _.findWhere sorted, {email: @_getSender().email}
|
|
||||||
sorted = _.without sorted, sender
|
|
||||||
sorted.unshift sender
|
|
||||||
|
|
||||||
sorted.forEach (p) ->
|
|
||||||
p.id = p.name+p.email
|
p.id = p.name+p.email
|
||||||
|
|
||||||
sorted
|
list
|
||||||
|
|
||||||
shouldComponentUpdate: (newProps, newState) ->
|
shouldComponentUpdate: (newProps, newState) ->
|
||||||
!_.isEqual(newProps.participants, @props.participants)
|
!_.isEqual(newProps.participants, @props.participants)
|
||||||
|
|
||||||
# TODO - this'll require poking DatabaseStore
|
|
||||||
# UPDATE: Please move these so they're injected via props from somewhere
|
|
||||||
# that has the thread object. DON'T QUERY HERE! (@ben)
|
|
||||||
_fromUserUnrepliedContext: ->
|
|
||||||
false
|
|
||||||
|
|
||||||
_fromUserGroupThreadContext: ->
|
|
||||||
false
|
|
||||||
|
|
||||||
_getSender: ->
|
|
||||||
undefined
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue