fix(frontend): use 'treat as favourite' preferences as favourites in member list

This commit is contained in:
Sam 2023-04-21 16:37:26 +02:00
parent 5594463a09
commit bd279a7dae
No known key found for this signature in database
GPG Key ID: B4EF20DDE721CAA1
1 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,11 @@
<script lang="ts"> <script lang="ts">
import { memberAvatars, WordStatus, type PartialMember, type User } from "$lib/api/entities"; import defaultPreferences from "$lib/api/default_preferences";
import {
memberAvatars,
type PartialMember,
type User,
type CustomPreferences,
} from "$lib/api/entities";
import FallbackImage from "./FallbackImage.svelte"; import FallbackImage from "./FallbackImage.svelte";
export let user: User; export let user: User;
@ -7,9 +13,12 @@
let pronouns: string | undefined; let pronouns: string | undefined;
let mergedPreferences: CustomPreferences;
$: mergedPreferences = Object.assign(defaultPreferences, user.custom_preferences);
const getPronouns = (member: PartialMember) => { const getPronouns = (member: PartialMember) => {
const filteredPronouns = member.pronouns.filter( const filteredPronouns = member.pronouns.filter(
(pronouns) => pronouns.status === WordStatus.Favourite, (entry) => (mergedPreferences[entry.status] || { favourite: false }).favourite,
); );
if (filteredPronouns.length === 0) { if (filteredPronouns.length === 0) {
return undefined; return undefined;