Skip to content

Commit

Permalink
[WiP] Add federation toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Feb 23, 2024
1 parent 6160807 commit 3cce898
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { countableText } from '../util/counter';
import { CharacterCounter } from './character_counter';
import { ContentTypeButton } from './content_type_button';
import { EditIndicator } from './edit_indicator';
import { FederationButton } from './federation_button';
import { NavigationBar } from './navigation_bar';
import { PollForm } from "./poll_form";
import { ReplyIndicator } from './reply_indicator';
Expand Down Expand Up @@ -301,6 +302,7 @@ class ComposeForm extends ImmutablePureComponent {
<PollButtonContainer />
{!this.props.spoilerAlwaysOn && <SpoilerButtonContainer />}
<ContentTypeButton />
<FederationButton />
<EmojiPickerDropdown onPickEmoji={this.handleEmojiPick} />
<CharacterCounter max={maxChars} text={this.getFulltextForCharacterCounting()} />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useCallback } from 'react';

import { useIntl, defineMessages } from 'react-intl';

import ShareOffIcon from '@/material-icons/400-24px/share_off.svg?react';
import { changeComposeAdvancedOption } from 'flavours/glitch/actions/compose';
import { IconButton } from 'flavours/glitch/components/icon_button';
import { useAppSelector, useAppDispatch } from 'flavours/glitch/store';

const messages = defineMessages({
enable_local_only: { id: 'compose.federation.enable_local_only', defaultMessage: 'Disallow federation for this post' },
disable_local_only: { id: 'compose.federation.disable_local_only', defaultMessage: 'Allow federation for this post' },
});

export const FederationButton = () => {
const intl = useIntl();

const disabled = useAppSelector((state) => state.getIn(['compose', 'id']) !== null);
const active = useAppSelector((state) => state.getIn(['compose', 'advanced_options', 'do_not_federate']));

const dispatch = useAppDispatch();

const handleClick = useCallback(() => {
dispatch(changeComposeAdvancedOption('do_not_federate', !active));
}, [active, dispatch]);

return (
<IconButton
onClick={handleClick}
icon={'share-off'}
iconComponent={ShareOffIcon}
title={intl.formatMessage(active ? messages.disable_local_only : messages.enable_local_only)}
active={active}
size={18}
disabled={disabled}
inverted
/>
);
};
1 change: 1 addition & 0 deletions app/javascript/material-icons/400-24px/share_off-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/javascript/material-icons/400-24px/share_off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3cce898

Please sign in to comment.