feat: read/write improved fields for users, read improved names/pronouns for users
This commit is contained in:
parent
7669595586
commit
c6537c920d
8 changed files with 87 additions and 127 deletions
|
@ -51,11 +51,12 @@ export interface Pronoun {
|
|||
|
||||
export interface Field {
|
||||
name: string;
|
||||
favourite: Arr<string>;
|
||||
okay: Arr<string>;
|
||||
jokingly: Arr<string>;
|
||||
friends_only: Arr<string>;
|
||||
avoid: Arr<string>;
|
||||
entries: Arr<FieldEntry>;
|
||||
}
|
||||
|
||||
export interface FieldEntry {
|
||||
value: string;
|
||||
status: WordStatus;
|
||||
}
|
||||
|
||||
export interface APIError {
|
||||
|
|
|
@ -199,31 +199,11 @@ export class Pronouns extends Label {
|
|||
export class Field {
|
||||
name: string;
|
||||
labels: Label[];
|
||||
constructor({
|
||||
name,
|
||||
favourite,
|
||||
okay,
|
||||
jokingly,
|
||||
friends_only,
|
||||
avoid,
|
||||
}: API.Field) {
|
||||
constructor({ name, entries }: API.Field) {
|
||||
this.name = name;
|
||||
function transpose(arr: API.Arr<string>, status: LabelStatus): Label[] {
|
||||
return (arr ?? []).map(
|
||||
(text) =>
|
||||
new Label({
|
||||
displayText: null,
|
||||
text,
|
||||
status,
|
||||
})
|
||||
);
|
||||
}
|
||||
this.labels = [
|
||||
...transpose(favourite, LabelStatus.Favourite),
|
||||
...transpose(okay, LabelStatus.Okay),
|
||||
...transpose(jokingly, LabelStatus.Jokingly),
|
||||
...transpose(friends_only, LabelStatus.FriendsOnly),
|
||||
...transpose(avoid, LabelStatus.Avoid),
|
||||
];
|
||||
this.labels =
|
||||
entries?.map(
|
||||
(e) => new Label({ displayText: null, text: e.value, status: e.status })
|
||||
) ?? [];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue