From 70836fea14aef52e29e33725a084a1b0ccaab95a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Fri, 5 Dec 2025 18:57:46 +0100 Subject: [PATCH] pl-fe: fix profile fields editing on Mastodon, also pl-api params fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-api/lib/entities/account.ts | 2 +- packages/pl-api/lib/params/settings.ts | 8 ++++---- .../pl-fe/src/pages/settings/edit-profile.tsx | 19 +++++++++++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/pl-api/lib/entities/account.ts b/packages/pl-api/lib/entities/account.ts index 5f260ccdb..50d9ac030 100644 --- a/packages/pl-api/lib/entities/account.ts +++ b/packages/pl-api/lib/entities/account.ts @@ -153,7 +153,7 @@ const baseAccountSchema = v.object({ pronouns: v.fallback(v.array(v.string()), []), /** Mention policy */ - mention_policy: v.fallback(v.picklist(['none', 'only_known', 'only_followers']), 'none'), + mention_policy: v.fallback(v.picklist(['none', 'only_known', 'only_contacts']), 'none'), /** The reported subscribers of this user */ subscribers_count: v.fallback(v.number(), 0), /** Identity proofs */ diff --git a/packages/pl-api/lib/params/settings.ts b/packages/pl-api/lib/params/settings.ts index 104bdea12..6ead58aff 100644 --- a/packages/pl-api/lib/params/settings.ts +++ b/packages/pl-api/lib/params/settings.ts @@ -71,7 +71,7 @@ interface UpdateCredentialsParams { /** Boolean. Whether public posts should be searchable to anyone. */ indexable?: boolean; /** Hash. The profile fields to be set. Inside this hash, the key is an integer cast to a string (although the exact integer does not matter), and the value is another hash including name and value. By default, max 4 fields. */ - fields_attributes?: Array<{ + fields_attributes?: Record { const handleSubmit: React.FormEventHandler = (event) => { const promises = []; - const params = { ...data }; - if (params.fields_attributes?.length === 0) params.fields_attributes = [{ name: '', value: '' }]; + const { fields_attributes, ...rest } = data; + const params: UpdateCredentialsParams = { + ...rest, + }; + + if (fields_attributes?.length === 0) params.fields_attributes = { '0': { name: '', value: '' } }; + else if (fields_attributes) params.fields_attributes = Object.fromEntries( + fields_attributes.map((field, i) => [i.toString(), field]), + ); if (header.file !== undefined) params.header = header.file || ''; if (avatar.file !== undefined) params.avatar = avatar.file || '';