#111 fix cannot add "any" pronouns to profile

This commit is contained in:
Avris 2021-03-09 16:36:17 +01:00
parent 1f2d86b3dd
commit 4e8211e096
3 changed files with 24 additions and 7 deletions

View File

@ -5,7 +5,7 @@
<span v-else><Spelling>{{part.str}}</Spelling></span>
</span>
<small v-if="link">
(<nuxt-link :to="'/' + pronoun.canonicalName"><Spelling>{{ pronoun.canonicalName }}</Spelling></nuxt-link>)
(<nuxt-link :to="'/' + pronoun.canonicalName"><Spelling :text="pronoun.canonicalName"/></nuxt-link>)
</small>
<template v-if="config.pronunciation.enabled && pronounce && pronoun.pronounceable && example.pronounce(pronoun)">
<a v-for="(link, name) in pronunciationLinks"

View File

@ -76,7 +76,7 @@
<ul class="list-unstyled">
<li v-for="{link, pronoun, opinion} in pronounOpinions">
<Opinion :word="pronoun.name(glue) + (pronoun.smallForm ? '/' + pronoun.morphemes[pronoun.smallForm] : '')" :opinion="opinion" :link="`/${link}`"/>
<Opinion :word="typeof pronoun === 'string' ? pronoun : (pronoun.name(glue) + (pronoun.smallForm ? '/' + pronoun.morphemes[pronoun.smallForm] : ''))" :opinion="opinion" :link="`/${link}`"/>
</li>
</ul>
</div>
@ -179,6 +179,16 @@
.replace(new RegExp('^' + this.$base.replace(/^https?:\/\//, '')), '')
.replace(new RegExp('^/'), '')
);
if (link === this.config.pronouns.any) {
pronounOpinions.push({
link,
pronoun: link,
opinion: this.profile.pronouns[pronoun],
});
continue;
}
const pronounEntity = buildPronoun(pronouns, link);
if (pronounEntity) {
@ -195,6 +205,9 @@
let mainPronoun = buildPronoun(pronouns, this.config.profile.flags.defaultPronoun);
let mainOpinion = -1;
for (let {pronoun, opinion} of this.pronounOpinions) {
if (typeof pronoun === 'string') {
continue;
}
if (opinion === 2) {
opinion = 0.5;
}

View File

@ -243,7 +243,7 @@
this.$router.push(`/@${this.$user().username}`)
},
normalisePronoun(pronoun) {
const link = decodeURIComponent(
return decodeURIComponent(
pronoun
.toLowerCase()
.trim()
@ -251,11 +251,15 @@
.replace(new RegExp('^' + this.$base.replace(/^https?:\/\//, '')), '')
.replace(new RegExp('^/'), '')
);
return buildPronoun(pronouns, link);
},
normaliseAndBuildPronoun(pronoun) {
return buildPronoun(pronouns, this.normalisePronoun(pronoun));
},
validatePronoun(pronoun) {
return this.normalisePronoun(pronoun) ? null : 'profile.pronounsNotFound'
pronoun = this.normalisePronoun(pronoun);
return pronoun === this.config.pronouns.any || buildPronoun(pronouns, pronoun)
? null
: 'profile.pronounsNotFound'
},
},
computed: {
@ -267,7 +271,7 @@
opinion = 0.5;
}
if (opinion > mainOpinion) {
const p = this.normalisePronoun(pronoun);
const p = this.normaliseAndBuildPronoun(pronoun);
if (p) {
mainPronoun = p;
mainOpinion = opinion;