mirror of
https://github.com/urbit/shrub.git
synced 2025-01-03 10:02:32 +03:00
invite-search: handle suggestions for short searches
Triggers invitee suggestions after one character of input. To compensate for the potential explosion of suggestions, we tighten our group searching criteria and truncate the ship suggestions on short searches. Also addresses a bug where names of groups were not being downcased before search. Fixes #2635
This commit is contained in:
parent
eef6e56dca
commit
e7887b34c3
@ -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 }
|
||||
});
|
||||
|
@ -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 }
|
||||
});
|
||||
|
@ -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 }
|
||||
});
|
||||
|
@ -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 }
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user