Merge "Remove uppercase of first character of auprefix"

This commit is contained in:
jenkins-bot 2021-10-05 20:57:58 +00:00 committed by Gerrit Code Review
commit c7d82f4ddc
2 changed files with 6 additions and 8 deletions

View file

@ -7,7 +7,7 @@
"descriptionmsg": "discussiontools-desc", "descriptionmsg": "discussiontools-desc",
"manifest_version": 2, "manifest_version": 2,
"requires": { "requires": {
"MediaWiki": ">= 1.37.0", "MediaWiki": ">= 1.38.0",
"extensions": { "extensions": {
"VisualEditor": ">= 0.1.2", "VisualEditor": ">= 0.1.2",
"Linter": "*" "Linter": "*"

View file

@ -91,19 +91,17 @@ MWUsernameCompletionAction.prototype.insertAndOpen = function () {
}; };
MWUsernameCompletionAction.prototype.getSuggestions = function ( input ) { MWUsernameCompletionAction.prototype.getSuggestions = function ( input ) {
var capitalizedInput = input.length > 0 && input[ 0 ].toUpperCase() + input.slice( 1 ), var title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, input ),
title = mw.Title.makeTitle( mw.config.get( 'wgNamespaceIds' ).user, input ),
validatedInput = title ? input : '', validatedInput = title ? input : '',
action = this; action = this;
this.api.abort(); // Abort all unfinished API requests this.api.abort(); // Abort all unfinished API requests
var apiPromise; var apiPromise;
if ( capitalizedInput && !this.searchedPrefixes[ capitalizedInput ] ) { if ( input.length > 0 && !this.searchedPrefixes[ input ] ) {
apiPromise = this.api.get( { apiPromise = this.api.get( {
action: 'query', action: 'query',
list: 'allusers', list: 'allusers',
// Prefix of list=allusers is case sensitive, and users are stored in the DB capitalized, so: auprefix: input,
auprefix: capitalizedInput,
aulimit: this.limit aulimit: this.limit
} ).then( function ( response ) { } ).then( function ( response ) {
var suggestions = response.query.allusers.map( function ( user ) { var suggestions = response.query.allusers.map( function ( user ) {
@ -117,7 +115,7 @@ MWUsernameCompletionAction.prototype.getSuggestions = function ( input ) {
action.remoteUsers.push.apply( action.remoteUsers, suggestions ); action.remoteUsers.push.apply( action.remoteUsers, suggestions );
action.remoteUsers.sort(); action.remoteUsers.sort();
action.searchedPrefixes[ capitalizedInput ] = true; action.searchedPrefixes[ input ] = true;
} ); } );
} else { } else {
apiPromise = ve.createDeferred().resolve().promise(); apiPromise = ve.createDeferred().resolve().promise();
@ -130,7 +128,7 @@ MWUsernameCompletionAction.prototype.getSuggestions = function ( input ) {
return action.filterSuggestionsForInput( return action.filterSuggestionsForInput(
action.localUsers action.localUsers
// Show no remote users if no input provided // Show no remote users if no input provided
.concat( capitalizedInput ? action.remoteUsers : [] ), .concat( input.length > 0 ? action.remoteUsers : [] ),
// TODO: Consider showing IP users // TODO: Consider showing IP users
// * Change link to Special:Contributions/<ip> (localised) // * Change link to Special:Contributions/<ip> (localised)
// * Let users know that mentioning an IP will not create a notification? // * Let users know that mentioning an IP will not create a notification?