mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
Improve mention search functionality in PostCreator
This commit is contained in:
parent
1bbdbe7281
commit
0b41f620d8
@ -335,10 +335,17 @@ export default class PostCreator extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOnMentionSearch = lodash.debounce(async (value) => {
|
handleOnMentionSearch = lodash.debounce(async (value) => {
|
||||||
const results = await SearchModel.userSearch(`username:${value}`)
|
if (value === "") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const results = await SearchModel.search(`${value}`, {
|
||||||
|
fields: "users",
|
||||||
|
limit: 5,
|
||||||
|
})
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
mentionsLoadedData: results,
|
mentionsLoadedData: results.users.items,
|
||||||
})
|
})
|
||||||
}, 300)
|
}, 300)
|
||||||
|
|
||||||
@ -674,13 +681,20 @@ export default class PostCreator extends React.Component {
|
|||||||
draggable={false}
|
draggable={false}
|
||||||
prefix="@"
|
prefix="@"
|
||||||
allowClear
|
allowClear
|
||||||
|
onBlur={() => {
|
||||||
|
this.setState({ mentionsLoadedData: [] })
|
||||||
|
}}
|
||||||
options={this.state.mentionsLoadedData.map((item) => {
|
options={this.state.mentionsLoadedData.map((item) => {
|
||||||
return {
|
return {
|
||||||
key: item.id,
|
key: item.id,
|
||||||
value: item.username,
|
value: item.username,
|
||||||
label: (
|
label: (
|
||||||
<>
|
<>
|
||||||
<antd.Avatar src={item.avatar} />
|
<antd.Avatar
|
||||||
|
size={24}
|
||||||
|
src={item.avatar}
|
||||||
|
shape="square"
|
||||||
|
/>
|
||||||
<span>{item.username}</span>
|
<span>{item.username}</span>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user