Foxnouns.NET/Foxnouns.Frontend/app/lib/api/user.ts

123 lines
2.3 KiB
TypeScript
Raw Normal View History

2024-09-17 22:12:12 +02:00
export type PartialUser = {
2024-06-09 15:48:26 +02:00
id: string;
username: string;
2024-09-17 22:12:12 +02:00
display_name?: string | null;
avatar_url?: string | null;
custom_preferences: Record<string, CustomPreference>;
2024-09-17 22:12:12 +02:00
};
export type User = PartialUser & {
2024-06-09 15:48:26 +02:00
bio: string | null;
member_title: string | null;
links: string[];
2024-09-17 22:12:12 +02:00
names: FieldEntry[];
pronouns: Pronoun[];
fields: Field[];
2024-09-29 20:24:47 +02:00
flags: PrideFlag[];
2024-09-17 22:12:12 +02:00
};
export type UserWithMembers = User & { members: PartialMember[] };
export type UserWithHiddenFields = User & {
auth_methods?: unknown[];
member_list_hidden: boolean;
last_active: string;
2024-06-09 15:48:26 +02:00
};
export type UserSettings = {
dark_mode: boolean | null;
};
2024-09-17 22:12:12 +02:00
export type PartialMember = {
id: string;
name: string;
display_name: string | null;
bio: string | null;
avatar_url: string | null;
names: FieldEntry[];
pronouns: Pronoun[];
unlisted: boolean | null;
2024-09-17 22:12:12 +02:00
};
export type FieldEntry = {
value: string;
status: string;
};
export type Pronoun = FieldEntry & { display_text: string | null };
export type Field = {
name: string;
entries: FieldEntry[];
};
2024-09-29 20:24:47 +02:00
export type PrideFlag = {
id: string;
image_url: string;
name: string;
description: string | null;
};
export type CustomPreference = {
icon: string;
tooltip: string;
muted: boolean;
favourite: boolean;
size: PreferenceSize;
};
export enum PreferenceSize {
Large = "LARGE",
Normal = "NORMAL",
Small = "SMALL",
}
export function mergePreferences(prefs: Record<string, CustomPreference>) {
return Object.assign({}, defaultPreferences, prefs);
}
export const defaultPreferences = Object.freeze({
favourite: {
icon: "heart-fill",
tooltip: "Favourite",
size: PreferenceSize.Large,
muted: false,
favourite: true,
},
okay: {
icon: "hand-thumbs-up",
tooltip: "Okay",
size: PreferenceSize.Normal,
muted: false,
favourite: false,
},
jokingly: {
icon: "emoji-laughing",
tooltip: "Jokingly",
size: PreferenceSize.Normal,
muted: false,
favourite: false,
},
friends_only: {
icon: "people",
tooltip: "Friends only",
size: PreferenceSize.Normal,
muted: false,
favourite: false,
},
avoid: {
icon: "hand-thumbs-down",
tooltip: "Avoid",
size: PreferenceSize.Small,
muted: true,
favourite: false,
},
missing: {
icon: "question-lg",
tooltip: "Unknown (missing)",
size: PreferenceSize.Normal,
muted: false,
favourite: false,
},
});