diff --git a/pkg/interface/groups/src/js/components/lib/add-contact.js b/pkg/interface/groups/src/js/components/lib/add-contact.js index 4132f45655..18f2e51878 100644 --- a/pkg/interface/groups/src/js/components/lib/add-contact.js +++ b/pkg/interface/groups/src/js/components/lib/add-contact.js @@ -73,6 +73,7 @@ export class AddScreen extends Component { groups={props.groups} contacts={props.contacts} groupResults={false} + shipResults={true} invites={this.state.invites} setInvite={this.invChange} /> diff --git a/pkg/interface/groups/src/js/components/lib/invite-search.js b/pkg/interface/groups/src/js/components/lib/invite-search.js index b893a1194c..97a84c8a3b 100644 --- a/pkg/interface/groups/src/js/components/lib/invite-search.js +++ b/pkg/interface/groups/src/js/components/lib/invite-search.js @@ -102,37 +102,37 @@ export class InviteSearch extends Component { }); } - let shipMatches = this.state.peers.filter(e => { - return e.includes(searchTerm) && !this.props.invites.ships.includes(e); - }); - - for (let contact of this.state.contacts.keys()) { - let thisContact = this.state.contacts.get(contact); - let match = thisContact.filter(e => { - return e.toLowerCase().includes(searchTerm); + let shipMatches = []; + if (this.props.shipResults) { + shipMatches = this.state.peers.filter(e => { + return e.includes(searchTerm) && !this.props.invites.ships.includes(e); }); - if (match.length > 0) { - if (!(contact in shipMatches)) { - shipMatches.push(contact); + + for (let contact of this.state.contacts.keys()) { + let thisContact = this.state.contacts.get(contact); + let match = thisContact.filter(e => { + return e.toLowerCase().includes(searchTerm); + }); + if (match.length > 0) { + if (!(contact in shipMatches)) { + shipMatches.push(contact); + } } } + + let isValid = true; + if (!urbitOb.isValidPatp("~" + searchTerm)) { + isValid = false; + } + + if (shipMatches.length === 0 && isValid) { + shipMatches.push(searchTerm); + } } this.setState({ searchResults: { groups: groupMatches, ships: shipMatches } }); - - let isValid = true; - if (!urbitOb.isValidPatp("~" + searchTerm)) { - isValid = false; - } - - if (shipMatches.length === 0 && isValid) { - shipMatches.push(searchTerm); - this.setState({ - searchResults: { groups: groupMatches, ships: shipMatches } - }); - } } } @@ -209,6 +209,18 @@ export class InviteSearch extends Component { let participants =
; let searchResults = ; + let placeholder = ''; + if (props.shipResults) { + placeholder = 'ships'; + } + if (props.groupResults) { + if (placeholder.length > 0) { + placeholder = placeholder + ' or '; + } + placeholder = placeholder + 'existing groups'; + } + placeholder = 'Search for ' + placeholder; + let invErrElem = ; if (state.inviteError) { invErrElem = ( @@ -372,7 +384,7 @@ export class InviteSearch extends Component { "f7 ba b--gray3 b--gray2-d bg-gray0-d white-d pa3 w-100" + " db focus-b--black focus-b--white-d" } - placeholder="Search for ships or existing groups" + placeholder={placeholder} disabled={searchDisabled} rows={1} spellCheck={false} diff --git a/pkg/interface/groups/src/js/components/new.js b/pkg/interface/groups/src/js/components/new.js index dfca70bf5a..06bd980e48 100644 --- a/pkg/interface/groups/src/js/components/new.js +++ b/pkg/interface/groups/src/js/components/new.js @@ -134,6 +134,7 @@ export class NewScreen extends Component { groups={this.props.groups} contacts={this.props.contacts} groupResults={false} + shipResults={true} invites={this.state.invites} setInvite={this.invChange} /> diff --git a/pkg/interface/link/src/js/components/lib/invite-element.js b/pkg/interface/link/src/js/components/lib/invite-element.js index 5cafe8d74e..e7a1a728f7 100644 --- a/pkg/interface/link/src/js/components/lib/invite-element.js +++ b/pkg/interface/link/src/js/components/lib/invite-element.js @@ -57,6 +57,7 @@ export class InviteElement extends Component { groups={{}} contacts={props.contacts} groupResults={false} + shipResults={true} invites={{ groups: [], ships: this.state.members diff --git a/pkg/interface/link/src/js/components/lib/invite-search.js b/pkg/interface/link/src/js/components/lib/invite-search.js index d62710b821..4d497ec04d 100644 --- a/pkg/interface/link/src/js/components/lib/invite-search.js +++ b/pkg/interface/link/src/js/components/lib/invite-search.js @@ -102,37 +102,37 @@ export class InviteSearch extends Component { }); } - let shipMatches = this.state.peers.filter(e => { - return e.includes(searchTerm) && !this.props.invites.ships.includes(e); - }); - - for (let contact of this.state.contacts.keys()) { - let thisContact = this.state.contacts.get(contact); - let match = thisContact.filter(e => { - return e.toLowerCase().includes(searchTerm); + let shipMatches = []; + if (this.props.shipResults) { + shipMatches = this.state.peers.filter(e => { + return e.includes(searchTerm) && !this.props.invites.ships.includes(e); }); - if (match.length > 0) { - if (!(contact in shipMatches)) { - shipMatches.push(contact); + + for (let contact of this.state.contacts.keys()) { + let thisContact = this.state.contacts.get(contact); + let match = thisContact.filter(e => { + return e.toLowerCase().includes(searchTerm); + }); + if (match.length > 0) { + if (!(contact in shipMatches)) { + shipMatches.push(contact); + } } } + + let isValid = true; + if (!urbitOb.isValidPatp("~" + searchTerm)) { + isValid = false; + } + + if (shipMatches.length === 0 && isValid) { + shipMatches.push(searchTerm); + } } this.setState({ searchResults: { groups: groupMatches, ships: shipMatches } }); - - let isValid = true; - if (!urbitOb.isValidPatp("~" + searchTerm)) { - isValid = false; - } - - if (shipMatches.length === 0 && isValid) { - shipMatches.push(searchTerm); - this.setState({ - searchResults: { groups: groupMatches, ships: shipMatches } - }); - } } } @@ -209,6 +209,18 @@ export class InviteSearch extends Component { let participants = ; let searchResults = ; + let placeholder = ''; + if (props.shipResults) { + placeholder = 'ships'; + } + if (props.groupResults) { + if (placeholder.length > 0) { + placeholder = placeholder + ' or '; + } + placeholder = placeholder + 'existing groups'; + } + placeholder = 'Search for ' + placeholder; + let invErrElem = ; if (state.inviteError) { invErrElem = ( @@ -372,7 +384,7 @@ export class InviteSearch extends Component { "f7 ba b--gray3 b--gray2-d bg-gray0-d white-d pa3 w-100" + " db focus-b--black focus-b--white-d" } - placeholder="Search for ships or existing groups" + placeholder={placeholder} disabled={searchDisabled} rows={1} spellCheck={false} diff --git a/pkg/interface/link/src/js/components/new.js b/pkg/interface/link/src/js/components/new.js index a19c3590ce..3dbb4f3ca1 100644 --- a/pkg/interface/link/src/js/components/new.js +++ b/pkg/interface/link/src/js/components/new.js @@ -221,6 +221,7 @@ export class NewScreen extends Component { groups={props.groups} contacts={props.contacts} groupResults={true} + shipResults={true} invites={{ groups: state.groups, ships: state.ships diff --git a/pkg/interface/publish/src/js/components/lib/invite-search.js b/pkg/interface/publish/src/js/components/lib/invite-search.js index 72c157f3b6..2c8a57bdb4 100644 --- a/pkg/interface/publish/src/js/components/lib/invite-search.js +++ b/pkg/interface/publish/src/js/components/lib/invite-search.js @@ -102,37 +102,37 @@ export class InviteSearch extends Component { }); } - let shipMatches = this.state.peers.filter(e => { - return e.includes(searchTerm) && !this.props.invites.ships.includes(e); - }); - - for (let contact of this.state.contacts.keys()) { - let thisContact = this.state.contacts.get(contact); - let match = thisContact.filter(e => { - return e.toLowerCase().includes(searchTerm); + let shipMatches = []; + if (this.props.shipResults) { + shipMatches = this.state.peers.filter(e => { + return e.includes(searchTerm) && !this.props.invites.ships.includes(e); }); - if (match.length > 0) { - if (!(contact in shipMatches)) { - shipMatches.push(contact); + + for (let contact of this.state.contacts.keys()) { + let thisContact = this.state.contacts.get(contact); + let match = thisContact.filter(e => { + return e.toLowerCase().includes(searchTerm); + }); + if (match.length > 0) { + if (!(contact in shipMatches)) { + shipMatches.push(contact); + } } } + + let isValid = true; + if (!urbitOb.isValidPatp("~" + searchTerm)) { + isValid = false; + } + + if (shipMatches.length === 0 && isValid) { + shipMatches.push(searchTerm); + } } this.setState({ searchResults: { groups: groupMatches, ships: shipMatches } }); - - let isValid = true; - if (!urbitOb.isValidPatp("~" + searchTerm)) { - isValid = false; - } - - if (shipMatches.length === 0 && isValid) { - shipMatches.push(searchTerm); - this.setState({ - searchResults: { groups: groupMatches, ships: shipMatches } - }); - } } } @@ -209,6 +209,18 @@ export class InviteSearch extends Component { let participants = ; let searchResults = ; + let placeholder = ''; + if (props.shipResults) { + placeholder = 'ships'; + } + if (props.groupResults) { + if (placeholder.length > 0) { + placeholder = placeholder + ' or '; + } + placeholder = placeholder + 'existing groups'; + } + placeholder = 'Search for ' + placeholder; + let invErrElem = ; if (state.inviteError) { invErrElem = ( @@ -372,7 +384,7 @@ export class InviteSearch extends Component { "f7 ba b--gray3 b--gray2-d bg-gray0-d white-d pa3 w-100" + " db focus-b--black focus-b--white-d" } - placeholder="Search for ships or existing groups" + placeholder={placeholder} disabled={searchDisabled} rows={1} spellCheck={false} diff --git a/pkg/interface/publish/src/js/components/lib/new.js b/pkg/interface/publish/src/js/components/lib/new.js index 188d8e5846..f00cd0a212 100644 --- a/pkg/interface/publish/src/js/components/lib/new.js +++ b/pkg/interface/publish/src/js/components/lib/new.js @@ -189,6 +189,7 @@ export class NewScreen extends Component {