Merge pull request #38 from ItsVipra/3-edge-cases

Add a list of fieldnames to compare against
This commit is contained in:
Vivien 2023-07-04 22:10:38 +02:00 committed by GitHub
commit 4a5f5b2588
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View file

@ -32,7 +32,7 @@ checkSite();
* If so creates an 'readystatechange' EventListener, with callback to main()
*/
async function checkSite() {
await getSettings();
getSettings();
const requestDest = location.protocol + "//" + hostName + "/api/v1/instance";
const response = await fetch(requestDest);

View file

@ -4,6 +4,7 @@ import { normaliseAccountName } from "./protootshelpers";
const cacheMaxAge = 24 * 60 * 60 * 1000; // time after which cached pronouns should be checked again: 24h
let conversationsCache;
const fieldNames = ["pronouns", "pronoun", "professional nouns", "pronomen"];
/**
* Fetches pronouns associated with account name.
@ -172,10 +173,8 @@ function getPronounField(status, accountName) {
const fields = account.fields;
for (const field of fields) {
//match fields against "pronouns"
//TODO: multiple languages -> match against list
if (field.name.toLowerCase().includes("pronouns")) {
//TODO: see https://github.com/ItsVipra/ProToots/issues/28
//match fields against fieldNames
if (fieldNames.includes(field.name.toLowerCase())) {
debug(`${account.acct}: ${field.value}`);
cachePronouns(accountName, field.value);

View file