From e22a88b512be8cfacc42447d855698dad73bef5f Mon Sep 17 00:00:00 2001 From: fusagiko / takayamaki <24884114+takayamaki@users.noreply.github.com> Date: Tue, 9 May 2023 19:09:32 +0900 Subject: [PATCH] [Glitch] Add more detailed type annotation for Account Port 6579e3af7d6eb2774eae3d16bb1c9b7772fb58ec to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/types/resources.ts | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/types/resources.ts b/app/javascript/flavours/glitch/types/resources.ts index 28fad2719a..0906504150 100644 --- a/app/javascript/flavours/glitch/types/resources.ts +++ b/app/javascript/flavours/glitch/types/resources.ts @@ -1,10 +1,54 @@ import type { Record } from 'immutable'; -type AccountValues = { - id: number; +type CustomEmoji = Record<{ + shortcode: string; + static_url: string; + url: string; +}>; + +type AccountField = Record<{ + name: string; + value: string; + verified_at: string | null; +}>; + +type AccountApiResponseValues = { + acct: string; avatar: string; avatar_static: string; - [key: string]: any; + bot: boolean; + created_at: string; + discoverable: boolean; + display_name: string; + emojis: CustomEmoji[]; + fields: AccountField[]; + followers_count: number; + following_count: number; + group: boolean; + header: string; + header_static: string; + id: string; + last_status_at: string; + locked: boolean; + note: string; + statuses_count: number; + url: string; + username: string; }; -export type Account = Record; +type NormalizedAccountField = Record<{ + name_emojified: string; + value_emojified: string; + value_plain: string; +}>; + +type NormalizedAccountValues = { + display_name_html: string; + fields: NormalizedAccountField[]; + note_emojified: string; + note_plain: string; +}; + +export type Account = Record< + AccountApiResponseValues & NormalizedAccountValues +>;