(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 class="d-flex align-items-center">
<ForeignPronoun
v-for="pronoun in selectMainPronouns(user.profiles[locale].pronouns)"
v-for="pronoun in selectMainPronouns(user.profiles[locale])"
:key="pronoun"
:pronoun="pronoun"
:locale="locale"
@ -253,7 +253,7 @@ export default {
mixins: [mainPronoun],
async asyncData({ app, route }) {
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() {
@ -359,13 +359,25 @@ export default {
clearInterval(this.cardCheckHandle);
}
},
selectMainPronouns(pronouns) {
selectMainPronouns(profile) {
const best = [];
for (const { value: pronoun, opinion } of pronouns) {
const opinionValue = opinions[opinion]?.value || 0;
for (const { value: pronoun, opinion } of profile.pronouns) {
const opinionValue = opinions[opinion]?.value;
if (opinionValue !== undefined) {
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);
}
}
}
return best.slice(0, 3);