diff --git a/pkg/interface/chat/src/js/components/lib/invite-search.js b/pkg/interface/chat/src/js/components/lib/invite-search.js index dc6cf8a200..0378c0f91a 100644 --- a/pkg/interface/chat/src/js/components/lib/invite-search.js +++ b/pkg/interface/chat/src/js/components/lib/invite-search.js @@ -88,11 +88,11 @@ export class InviteSearch extends Component { this.setState({ searchValue: event.target.value }); - if (searchTerm.length < 2) { + if (searchTerm.length < 1) { this.setState({ searchResults: { groups: [], ships: [] } }); } - if (searchTerm.length > 2) { + if (searchTerm.length > 0) { if (this.state.inviteError === true) { this.setState({ inviteError: false }); } @@ -100,7 +100,7 @@ export class InviteSearch extends Component { let groupMatches = []; if (this.props.groupResults) { groupMatches = this.state.groups.filter(e => { - return (e[0].includes(searchTerm) || e[1].includes(searchTerm)); + return (e[0].includes(searchTerm) || e[1].toLowerCase().includes(searchTerm)); }); } @@ -141,6 +141,15 @@ export class InviteSearch extends Component { this.setState({ selected: newSelection }) } + + if(searchTerm.length < 3) { + groupMatches = groupMatches.filter(([, name]) => + name.toLowerCase().split(' ').some(s => s.startsWith(searchTerm)) + ).sort((a,b) => a[1].length - b[1].length); + + shipMatches = shipMatches.slice(0,3); + } + this.setState({ searchResults: { groups: groupMatches, ships: shipMatches } }); 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 6dce2d5956..c095b29679 100644 --- a/pkg/interface/groups/src/js/components/lib/invite-search.js +++ b/pkg/interface/groups/src/js/components/lib/invite-search.js @@ -89,11 +89,11 @@ export class InviteSearch extends Component { this.setState({ searchValue: event.target.value }); - if (searchTerm.length < 2) { + if (searchTerm.length < 1) { this.setState({ searchResults: { groups: [], ships: [] } }); } - if (searchTerm.length > 2) { + if (searchTerm.length > 0) { if (this.state.inviteError === true) { this.setState({ inviteError: false }); } @@ -101,7 +101,7 @@ export class InviteSearch extends Component { let groupMatches = []; if (this.props.groupResults) { groupMatches = this.state.groups.filter(e => { - return e[0].includes(searchTerm) || e[1].includes(searchTerm); + return e[0].includes(searchTerm) || e[1].toLowerCase().includes(searchTerm); }); } @@ -142,6 +142,15 @@ export class InviteSearch extends Component { this.setState({ selected: newSelection }) } + + if(searchTerm.length < 3) { + groupMatches = groupMatches.filter(([, name]) => + name.toLowerCase().split(' ').some(s => s.startsWith(searchTerm)) + ).sort((a,b) => a[1].length - b[1].length); + + shipMatches = shipMatches.slice(0,3); + } + this.setState({ searchResults: { groups: groupMatches, ships: shipMatches } }); 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 734639e38e..1f2213bb6c 100644 --- a/pkg/interface/link/src/js/components/lib/invite-search.js +++ b/pkg/interface/link/src/js/components/lib/invite-search.js @@ -89,11 +89,11 @@ export class InviteSearch extends Component { this.setState({ searchValue: event.target.value }); - if (searchTerm.length < 2) { + if (searchTerm.length < 1) { this.setState({ searchResults: { groups: [], ships: [] } }); } - if (searchTerm.length > 2) { + if (searchTerm.length > 0) { if (this.state.inviteError === true) { this.setState({ inviteError: false }); } @@ -101,7 +101,7 @@ export class InviteSearch extends Component { let groupMatches = []; if (this.props.groupResults) { groupMatches = this.state.groups.filter(e => { - return e[0].includes(searchTerm) || e[1].includes(searchTerm); + return e[0].includes(searchTerm) || e[1].toLowerCase().includes(searchTerm); }); } @@ -142,6 +142,14 @@ export class InviteSearch extends Component { this.setState({ selected: newSelection }) } + if(searchTerm.length < 3) { + groupMatches = groupMatches.filter(([, name]) => + name.toLowerCase().split(' ').some(s => s.startsWith(searchTerm)) + ).sort((a,b) => a[1].length - b[1].length); + + shipMatches = shipMatches.slice(0,3); + } + this.setState({ searchResults: { groups: groupMatches, ships: shipMatches } }); 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 6f8063b691..0db9e79896 100644 --- a/pkg/interface/publish/src/js/components/lib/invite-search.js +++ b/pkg/interface/publish/src/js/components/lib/invite-search.js @@ -89,11 +89,11 @@ export class InviteSearch extends Component { this.setState({ searchValue: event.target.value }); - if (searchTerm.length < 2) { + if (searchTerm.length < 1) { this.setState({ searchResults: { groups: [], ships: [] } }); } - if (searchTerm.length > 2) { + if (searchTerm.length > 0) { if (this.state.inviteError === true) { this.setState({ inviteError: false }); } @@ -101,7 +101,7 @@ export class InviteSearch extends Component { let groupMatches = []; if (this.props.groupResults) { groupMatches = this.state.groups.filter(e => { - return e[0].includes(searchTerm) || e[1].includes(searchTerm); + return e[0].includes(searchTerm) || e[1].toLowerCase().includes(searchTerm); }); } @@ -142,6 +142,14 @@ export class InviteSearch extends Component { this.setState({ selected: newSelection }) } + if(searchTerm.length < 3) { + groupMatches = groupMatches.filter(([, name]) => + name.toLowerCase().split(' ').some(s => s.startsWith(searchTerm)) + ).sort((a,b) => a[1].length - b[1].length); + + shipMatches = shipMatches.slice(0,3); + } + this.setState({ searchResults: { groups: groupMatches, ships: shipMatches } });