Fix composer offering to edit federation settings for an existing post

This commit is contained in:
Claire 2024-02-23 17:34:11 +01:00
parent 23dc650596
commit e62cd93650
2 changed files with 5 additions and 1 deletions

View File

@ -7,7 +7,7 @@ import { IconButton } from 'flavours/glitch/components/icon_button';
import DropdownMenu from './dropdown_menu'; import DropdownMenu from './dropdown_menu';
export const DropdownIconButton = ({ value, icon, onChange, iconComponent, title, options }) => { export const DropdownIconButton = ({ value, disabled, icon, onChange, iconComponent, title, options }) => {
const containerRef = useRef(null); const containerRef = useRef(null);
const [activeElement, setActiveElement] = useState(null); const [activeElement, setActiveElement] = useState(null);
@ -39,6 +39,7 @@ export const DropdownIconButton = ({ value, icon, onChange, iconComponent, title
return ( return (
<div ref={containerRef}> <div ref={containerRef}>
<IconButton <IconButton
disabled={disabled}
icon={icon} icon={icon}
onClick={handleToggle} onClick={handleToggle}
iconComponent={iconComponent} iconComponent={iconComponent}
@ -68,6 +69,7 @@ export const DropdownIconButton = ({ value, icon, onChange, iconComponent, title
DropdownIconButton.propTypes = { DropdownIconButton.propTypes = {
value: PropTypes.string.isRequired, value: PropTypes.string.isRequired,
disabled: PropTypes.bool,
icon: PropTypes.string, icon: PropTypes.string,
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
iconComponent: PropTypes.func.isRequired, iconComponent: PropTypes.func.isRequired,

View File

@ -20,6 +20,7 @@ const messages = defineMessages({
export const FederationButton = () => { export const FederationButton = () => {
const intl = useIntl(); const intl = useIntl();
const isEditing = useAppSelector((state) => state.getIn(['compose', 'id']) !== null);
const do_not_federate = useAppSelector((state) => state.getIn(['compose', 'advanced_options', 'do_not_federate'])); const do_not_federate = useAppSelector((state) => state.getIn(['compose', 'advanced_options', 'do_not_federate']));
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@ -34,6 +35,7 @@ export const FederationButton = () => {
return ( return (
<DropdownIconButton <DropdownIconButton
disabled={isEditing}
icon={do_not_federate ? 'link-slash' : 'link'} icon={do_not_federate ? 'link-slash' : 'link'}
iconComponent={do_not_federate ? ShareOffIcon : ShareIcon} iconComponent={do_not_federate ? ShareOffIcon : ShareIcon}
onChange={handleChange} onChange={handleChange}