From 04b32d9abc0af4b492c4c7c221a76b5465d5e2a3 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Mon, 6 Mar 2017 22:00:25 +0100 Subject: [PATCH] Improve order of mention auto-completes Suggest plain mention of username before explicitly replying to a specific post. Closes flarum/core#1118. --- .../js/forum/src/addComposerAutocomplete.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/extensions/mentions/js/forum/src/addComposerAutocomplete.js b/extensions/mentions/js/forum/src/addComposerAutocomplete.js index bdcd420ca..5eb7ba4b0 100644 --- a/extensions/mentions/js/forum/src/addComposerAutocomplete.js +++ b/extensions/mentions/js/forum/src/addComposerAutocomplete.js @@ -98,6 +98,18 @@ export default function addComposerAutocomplete() { const buildSuggestions = () => { 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 // post, then we can suggest other posts in the discussion to mention. // 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) { dropdown.props.items = suggestions; m.render($container[0], dropdown.render());