forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6160807
commit 22448ef
Showing
5 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/javascript/flavours/glitch/features/compose/components/federation_button.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.