From e3e787fc53122acec05c7d35c7304f94b0e5045c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 27 Jul 2024 11:57:46 +0200 Subject: [PATCH] GoToSocial: Support hide_collections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- src/features/edit-profile/index.tsx | 16 ++++++++++------ src/schemas/account.ts | 1 + src/utils/features.ts | 5 ++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/features/edit-profile/index.tsx b/src/features/edit-profile/index.tsx index faf27797da..7d1c34a051 100644 --- a/src/features/edit-profile/index.tsx +++ b/src/features/edit-profile/index.tsx @@ -120,6 +120,8 @@ interface AccountCredentials { header_description?: string; /** GoToSocial: Enable RSS feed for public posts */ enable_rss?: boolean; + /** GoToSocial: whether to publicly display followers/follows. */ + hide_collections?: boolean; } /** Convert an account into an update_credentials request object. */ @@ -127,7 +129,7 @@ const accountToCredentials = (account: Account): AccountCredentials => { const hideNetwork = hidesNetwork(account); return { - ...(pick(account, ['discoverable', 'bot', 'display_name', 'locked', 'location', 'avatar_description', 'header_description', 'enable_rss'])), + ...(pick(account, ['discoverable', 'bot', 'display_name', 'locked', 'location', 'avatar_description', 'header_description', 'enable_rss', 'hide_collections'])), note: account.source?.note ?? '', fields_attributes: [...account.source?.fields ?? []], stranger_notifications: account.pleroma?.notification_settings?.block_from_strangers === true, @@ -257,10 +259,12 @@ const EditProfile: React.FC = () => { const hide = e.target.checked; setData(prevData => ({ ...prevData, - hide_followers: hide, - hide_follows: hide, - hide_followers_count: hide, - hide_follows_count: hide, + ...(software === GOTOSOCIAL ? { hide_collections: hide } : { + hide_followers: hide, + hide_follows: hide, + hide_followers_count: hide, + hide_follows_count: hide, + }), })); }; @@ -372,7 +376,7 @@ const EditProfile: React.FC = () => { hint={} > diff --git a/src/schemas/account.ts b/src/schemas/account.ts index 6b02951eaa..586e3e5e91 100644 --- a/src/schemas/account.ts +++ b/src/schemas/account.ts @@ -49,6 +49,7 @@ const baseAccountSchema = z.object({ header: z.string().url().catch(headerMissing), header_description: z.string().catch(''), header_static: z.string().url().optional().catch(undefined), + hide_collections: z.boolean().catch(false), id: z.string(), last_status_at: z.string().datetime().optional().catch(undefined), local: z.boolean().catch(false), diff --git a/src/utils/features.ts b/src/utils/features.ts index 1fa6555722..4fbfebd849 100644 --- a/src/utils/features.ts +++ b/src/utils/features.ts @@ -580,7 +580,10 @@ const getInstanceFeatures = (instance: Instance) => { * Can hide follows/followers lists and counts. * @see PATCH /api/v1/accounts/update_credentials */ - hideNetwork: v.software === PLEROMA, + hideNetwork: any([ + v.software === PLEROMA, + v.software === GOTOSOCIAL, + ]), /** * Pleroma import API.