2024-01-26 02:41:31 +11:00
|
|
|
import { useCallback } from 'react';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
import { useIntl, defineMessages } from 'react-intl';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2024-02-24 02:32:13 +11:00
|
|
|
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
|
2024-01-26 02:41:31 +11:00
|
|
|
import { cancelReplyCompose } from 'mastodon/actions/compose';
|
|
|
|
import Account from 'mastodon/components/account';
|
|
|
|
import { IconButton } from 'mastodon/components/icon_button';
|
|
|
|
import { me } from 'mastodon/initial_state';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
import { ActionBar } from './action_bar';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2016-09-13 10:24:40 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
const messages = defineMessages({
|
|
|
|
cancel: { id: 'reply_indicator.cancel', defaultMessage: 'Cancel' },
|
|
|
|
});
|
2016-09-13 10:24:40 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
export const NavigationBar = () => {
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const intl = useIntl();
|
|
|
|
const account = useSelector(state => state.getIn(['accounts', me]));
|
|
|
|
const isReplying = useSelector(state => !!state.getIn(['compose', 'in_reply_to']));
|
2017-05-12 22:44:10 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
const handleCancelClick = useCallback(() => {
|
|
|
|
dispatch(cancelReplyCompose());
|
|
|
|
}, [dispatch]);
|
2016-09-13 10:24:40 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
return (
|
|
|
|
<div className='navigation-bar'>
|
|
|
|
<Account account={account} minimal />
|
|
|
|
{isReplying ? <IconButton title={intl.formatMessage(messages.cancel)} iconComponent={CloseIcon} onClick={handleCancelClick} /> : <ActionBar />}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|