GoToSocial: Support hide_collections

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-07-27 11:57:46 +02:00
parent 157b36a87f
commit e3e787fc53
3 changed files with 15 additions and 7 deletions

View file

@ -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={<FormattedMessage id='edit_profile.hints.hide_network' defaultMessage='Who you follow and who follows you will not be shown on your profile' />}
>
<Toggle
checked={account ? (data.hide_followers && data.hide_follows && data.hide_followers_count && data.hide_follows_count) : false}
checked={account ? (software === GOTOSOCIAL ? data.hide_collections : (data.hide_followers && data.hide_follows && data.hide_followers_count && data.hide_follows_count)) : false}
onChange={handleHideNetworkChange}
/>
</ListItem>

View file

@ -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),

View file

@ -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.