1
Fork 0

Make autocomplete aware of anonymous usernames.

This commit is contained in:
Bauke 2022-02-24 13:46:51 +01:00
parent 6b8c4e19cc
commit 1493b2c96b
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 9 additions and 4 deletions

View File

@ -30,11 +30,16 @@ export class AutocompleteFeature extends Component<Props, State> {
); );
// Get all the usernames on the page without their leading @s, and get // Get all the usernames on the page without their leading @s, and get
// all the username from the saved user labels. // all the usernames from the saved user labels.
const usernameElements = querySelectorAll<HTMLElement>('.link-user');
const usernames = [ const usernames = [
...querySelectorAll('.link-user').map((value) => ...usernameElements.map((value) => {
value.textContent!.replace(/^@/, '').toLowerCase(), if (props.settings.features.anonymizeUsernames) {
), return (value.dataset.trxUsername ?? '<unknown>').toLowerCase();
}
return value.textContent!.replace(/^@/, '').toLowerCase();
}),
...props.settings.data.userLabels.map((value) => value.username), ...props.settings.data.userLabels.map((value) => value.username),
].sort((a, b) => a.localeCompare(b)); ].sort((a, b) => a.localeCompare(b));