(profile)(fix) better handling of custom opinions when listing pronouns on pronouns.page/@username

This commit is contained in:
Andrea Vos 2024-02-07 20:26:25 +01:00
parent 9a6128df96
commit ce77ceebcd

View File

@ -215,7 +215,7 @@
</div> </div>
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<ForeignPronoun <ForeignPronoun
v-for="pronoun in selectMainPronouns(user.profiles[locale].pronouns)" v-for="pronoun in selectMainPronouns(user.profiles[locale])"
:key="pronoun" :key="pronoun"
:pronoun="pronoun" :pronoun="pronoun"
:locale="locale" :locale="locale"
@ -253,7 +253,7 @@ export default {
mixins: [mainPronoun], mixins: [mainPronoun],
async asyncData({ app, route }) { async asyncData({ app, route }) {
return { return {
user: await app.$axios.$get(`/profile/get/${encodeURIComponent(route.params.pathMatch)}?version=2&props=pronouns,flags&lprops[${app.context.env.LOCALE}]=all`), user: await app.$axios.$get(`/profile/get/${encodeURIComponent(route.params.pathMatch)}?version=2&props=pronouns,flags,opinions&lprops[${app.context.env.LOCALE}]=all`),
}; };
}, },
data() { data() {
@ -359,12 +359,24 @@ export default {
clearInterval(this.cardCheckHandle); clearInterval(this.cardCheckHandle);
} }
}, },
selectMainPronouns(pronouns) { selectMainPronouns(profile) {
const best = []; const best = [];
for (const { value: pronoun, opinion } of pronouns) { for (const { value: pronoun, opinion } of profile.pronouns) {
const opinionValue = opinions[opinion]?.value || 0; const opinionValue = opinions[opinion]?.value;
if (opinionValue >= 0) { if (opinionValue !== undefined) {
best.push(pronoun); if (opinionValue >= 0) {
best.push(pronoun);
}
} else {
const customOpinion = profile.opinions[opinion];
if (customOpinion !== undefined
&& customOpinion.colour !== 'grey'
&& customOpinion.style !== 'small'
&& !['ban', 'slash'].includes()
&& (!customOpinion.icon || '').endsWith('-slash')
) {
best.push(pronoun);
}
} }
} }