mirror of
https://github.com/flarum/core.git
synced 2025-07-28 20:20:34 +02:00
Improve order of mention auto-completes
Suggest plain mention of username before explicitly replying to a specific post. Closes flarum/core#1118.
This commit is contained in:
@@ -98,6 +98,18 @@ export default function addComposerAutocomplete() {
|
|||||||
const buildSuggestions = () => {
|
const buildSuggestions = () => {
|
||||||
const suggestions = [];
|
const suggestions = [];
|
||||||
|
|
||||||
|
// If the user has started to type a username, then suggest users
|
||||||
|
// matching that username.
|
||||||
|
if (typed) {
|
||||||
|
app.store.all('users').forEach(user => {
|
||||||
|
if (user.username().toLowerCase().substr(0, typed.length) !== typed) return;
|
||||||
|
|
||||||
|
suggestions.push(
|
||||||
|
makeSuggestion(user, '@' + user.username(), '', 'MentionsDropdown-user')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// If the user is replying to a discussion, or if they are editing a
|
// If the user is replying to a discussion, or if they are editing a
|
||||||
// post, then we can suggest other posts in the discussion to mention.
|
// post, then we can suggest other posts in the discussion to mention.
|
||||||
// We will add the 5 most recent comments in the discussion which
|
// We will add the 5 most recent comments in the discussion which
|
||||||
@@ -124,18 +136,6 @@ export default function addComposerAutocomplete() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user has started to type a username, then suggest users
|
|
||||||
// matching that username.
|
|
||||||
if (typed) {
|
|
||||||
app.store.all('users').forEach(user => {
|
|
||||||
if (user.username().toLowerCase().substr(0, typed.length) !== typed) return;
|
|
||||||
|
|
||||||
suggestions.push(
|
|
||||||
makeSuggestion(user, '@' + user.username(), '', 'MentionsDropdown-user')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (suggestions.length) {
|
if (suggestions.length) {
|
||||||
dropdown.props.items = suggestions;
|
dropdown.props.items = suggestions;
|
||||||
m.render($container[0], dropdown.render());
|
m.render($container[0], dropdown.render());
|
||||||
|
Reference in New Issue
Block a user