From a6f0ec160e984bcee6a16c82bec912ba98a8c56e Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 4 Aug 2025 09:49:12 +0200 Subject: [PATCH] [Glitch] Fix WebUI crashing for accounts with `null` URL Port 3caa318dfe6b5bb8c379a03941f1f42a84df0f7f to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/api_types/accounts.ts | 2 +- app/javascript/flavours/glitch/models/account.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/api_types/accounts.ts b/app/javascript/flavours/glitch/api_types/accounts.ts index b93054a1f6..913a201fef 100644 --- a/app/javascript/flavours/glitch/api_types/accounts.ts +++ b/app/javascript/flavours/glitch/api_types/accounts.ts @@ -37,7 +37,7 @@ export interface BaseApiAccountJSON { roles?: ApiAccountJSON[]; statuses_count: number; uri: string; - url: string; + url?: string; username: string; moved?: ApiAccountJSON; suspended?: boolean; diff --git a/app/javascript/flavours/glitch/models/account.ts b/app/javascript/flavours/glitch/models/account.ts index c4bf7f6422..ee59e7d393 100644 --- a/app/javascript/flavours/glitch/models/account.ts +++ b/app/javascript/flavours/glitch/models/account.ts @@ -45,7 +45,7 @@ const AccountRoleFactory = ImmutableRecord({ // Account export interface AccountShape extends Required< - Omit + Omit > { emojis: ImmutableList; fields: ImmutableList; @@ -55,6 +55,7 @@ export interface AccountShape note_plain: string | null; hidden: boolean; moved: string | null; + url: string; } export type Account = RecordOf; @@ -148,8 +149,8 @@ export function createAccountFromServerJSON(serverJSON: ApiAccountJSON) { note_emojified: emojify(accountNote, emojiMap), note_plain: unescapeHTML(accountNote), url: - accountJSON.url.startsWith('http://') || - accountJSON.url.startsWith('https://') + accountJSON.url?.startsWith('http://') || + accountJSON.url?.startsWith('https://') ? accountJSON.url : accountJSON.uri, });