Skip to content

Commit

Permalink
feat(composer): allow extensions to composer participant searching
Browse files Browse the repository at this point in the history
  • Loading branch information
emorikawa committed Nov 14, 2016
1 parent 177edc7 commit 211f0a6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal_packages/composer/lib/collapsed-participants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ export default class CollapsedParticipants extends React.Component {
>
<InjectedComponentSet
matching={{role: "Composer:RecipientChip"}}
exposedProps={{contact: contact}}
direction="column"
exposedProps={{contact: contact, collapsed: true}}
direction="row"
inline
/>
{name}
Expand Down
2 changes: 2 additions & 0 deletions internal_packages/composer/stylesheets/composer.less
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ body.platform-win32 {
}

.participant {
display: flex;
align-items: center;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
Expand Down
19 changes: 15 additions & 4 deletions src/components/participants-text-field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const TokenRenderer = (props) => {
<div className="participant">
<InjectedComponentSet
matching={{role: "Composer:RecipientChip"}}
exposedProps={{contact: props.token}}
direction="column"
exposedProps={{contact: props.token, collapsed: false}}
direction="row"
inline
/>
<span className="participant-primary">{chipText}</span>
Expand Down Expand Up @@ -72,9 +72,20 @@ export default class ParticipantsTextField extends React.Component {
}

_completionNode = (p) => {
if (p instanceof Contact) {
return (
<Menu.NameEmailItem name={p.name} email={p.email} key={p.id} />
);
}
return (
<Menu.NameEmailItem name={p.name} email={p.email} key={p.id} />
);
<InjectedComponentSet
ref="textField"
matching={{role: 'ContactSearchResults'}}
exposedProps={{token: p}}
direction="row"
inline
/>
)
}

_tokensForString = (string, options = {}) => {
Expand Down
14 changes: 11 additions & 3 deletions src/flux/stores/contact-store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ NylasStore = require 'nylas-store'
RegExpUtils = require '../../regexp-utils'
DatabaseStore = require('./database-store').default
AccountStore = require './account-store'
ComponentRegistry = require('../../registries/component-registry')
ContactRankingStore = require './contact-ranking-store'
_ = require 'underscore'

Expand Down Expand Up @@ -57,7 +58,7 @@ class ContactStore extends NylasStore
contact.name.toLowerCase().indexOf(search) isnt -1)
results.push(contact)
if results.length is limit
return Promise.resolve(results)
break

# If we haven't found enough items in memory, query for more from the
# database. Note that we ask for LIMIT * accountCount because we want to
Expand All @@ -75,9 +76,16 @@ class ContactStore extends NylasStore
queryResults = @_distinctByEmail(queryResults)

results = results.concat(queryResults)
results.length = limit if results.length > limit

return Promise.resolve(results)
extensions = ComponentRegistry.findComponentsMatching({
role: "ContactSearchResults"
})
return Promise.each extensions, (ext) =>
return ext.findAdditionalContacts(search, results).then (contacts) =>
results = contacts
.then () =>
results.length = limit
return Promise.resolve(results)

isValidContact: (contact) =>
return false unless contact instanceof Contact
Expand Down
1 change: 1 addition & 0 deletions static/components/tokenizing-text-field.less
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@

background: linear-gradient(to bottom, @token-top 0%, @token-bottom 100%);
box-shadow: @base-box-shadow;
vertical-align: middle;

.action {
position:absolute;
Expand Down

0 comments on commit 211f0a6

Please sign in to comment.