[Glitch] Profile editing: Adds bot toggle

Port 31d2885d959fc5eb8e45e0d6e6bfd9485615d05e to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo 2026-04-07 14:14:50 +02:00 committed by Claire
parent 631ec59f9c
commit 09f6759084

View File

@ -13,11 +13,15 @@ import { Button } from '@/flavours/glitch/components/button';
import { DismissibleCallout } from '@/flavours/glitch/components/callout/dismissible';
import { CustomEmojiProvider } from '@/flavours/glitch/components/emoji/context';
import { EmojiHTML } from '@/flavours/glitch/components/emoji/html';
import { ToggleField } from '@/flavours/glitch/components/form_fields';
import { useElementHandledLink } from '@/flavours/glitch/components/status/handled_link';
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
import { useCurrentAccountId } from '@/flavours/glitch/hooks/useAccountId';
import { autoPlayGif } from '@/flavours/glitch/initial_state';
import { fetchProfile } from '@/flavours/glitch/reducers/slices/profile_edit';
import {
fetchProfile,
patchProfile,
} from '@/flavours/glitch/reducers/slices/profile_edit';
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
import { AccountEditColumn, AccountEditEmptyColumn } from './components/column';
@ -108,6 +112,10 @@ export const messages = defineMessages({
id: 'account_edit.profile_tab.subtitle',
defaultMessage: 'Customize the tabs on your profile and what they display.',
},
advancedSettingsTitle: {
id: 'account_edit.advanced_settings.title',
defaultMessage: 'Advanced settings',
},
});
export const AccountEdit: FC = () => {
@ -117,7 +125,7 @@ export const AccountEdit: FC = () => {
const dispatch = useAppDispatch();
const { profile } = useAppSelector((state) => state.profileEdit);
const { profile, isPending } = useAppSelector((state) => state.profileEdit);
useEffect(() => {
void dispatch(fetchProfile());
}, [dispatch]);
@ -162,6 +170,10 @@ export const AccountEdit: FC = () => {
history.push('/profile/featured_tags');
}, [history]);
const handleBotToggle = useCallback(() => {
void dispatch(patchProfile({ bot: !profile?.bot }));
}, [dispatch, profile?.bot]);
// Normally we would use the account emoji, but we want all custom emojis to be available to render after editing.
const emojis = useAppSelector((state) => state.custom_emojis);
const htmlHandlers = useElementHandledLink({
@ -327,6 +339,26 @@ export const AccountEdit: FC = () => {
</Button>
}
/>
<AccountEditSection title={messages.advancedSettingsTitle}>
<ToggleField
checked={profile.bot}
onChange={handleBotToggle}
disabled={isPending}
label={
<FormattedMessage
id='account_edit.advanced_settings.bot_label'
defaultMessage='Automated account'
/>
}
hint={
<FormattedMessage
id='account_edit.advanced_settings.bot_hint'
defaultMessage='Signal to others that the account mainly performs automated actions and might not be monitored'
/>
}
/>
</AccountEditSection>
</CustomEmojiProvider>
</AccountEditColumn>
);