Merge branch 'modals-fix' into 'develop'

Fix links in modals

Closes #1240

See merge request soapbox-pub/soapbox!1974
environments/review-develop-3zknud/deployments/2187
marcin mikołajczak 2023-01-08 23:10:04 +00:00
commit ad1e58c95c
7 zmienionych plików z 34 dodań i 17 usunięć

Wyświetl plik

@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Posts: fix monospace font in Markdown code blocks.
- Modals: fix action buttons overflow
- Editing: don't insert edited posts to the top of the feed.
- Modals: close modal when navigating to a different page.
- Modals: fix "View context" button in media modal.
## [3.0.0] - 2022-12-25

Wyświetl plik

@ -15,14 +15,17 @@ import type { Account as AccountEntity } from 'soapbox/types/entities';
interface IInstanceFavicon {
account: AccountEntity,
disabled?: boolean,
}
const InstanceFavicon: React.FC<IInstanceFavicon> = ({ account }) => {
const InstanceFavicon: React.FC<IInstanceFavicon> = ({ account, disabled }) => {
const history = useHistory();
const handleClick: React.MouseEventHandler = (e) => {
e.stopPropagation();
if (disabled) return;
const timelineUrl = `/timeline/${account.domain}`;
if (!(e.ctrlKey || e.metaKey)) {
history.push(timelineUrl);
@ -32,7 +35,11 @@ const InstanceFavicon: React.FC<IInstanceFavicon> = ({ account }) => {
};
return (
<button className='w-4 h-4 flex-none focus:ring-primary-500 focus:ring-2 focus:ring-offset-2' onClick={handleClick}>
<button
className='w-4 h-4 flex-none focus:ring-primary-500 focus:ring-2 focus:ring-offset-2'
onClick={handleClick}
disabled={disabled}
>
<img src={account.favicon} alt='' title={account.domain} className='w-full max-h-full' />
</button>
);
@ -219,7 +226,7 @@ const Account = ({
<Text theme='muted' size='sm' direction='ltr' truncate>@{username}</Text>
{account.favicon && (
<InstanceFavicon account={account} />
<InstanceFavicon account={account} disabled={!withLinkToProfile} />
)}
{(timestamp) ? (

Wyświetl plik

@ -152,8 +152,10 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
const handleModalOpen = () => {
modalHistoryKey.current = Date.now();
unlistenHistory.current = history.listen((_, action) => {
if (action === 'POP') {
unlistenHistory.current = history.listen(({ state }, action) => {
if (!(state as any)?.soapboxModalKey) {
onClose();
} else if (action === 'POP') {
handleOnClose();
if (onCancel) onCancel();
@ -165,12 +167,10 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
if (unlistenHistory.current) {
unlistenHistory.current();
}
if (!['FAVOURITES', 'MENTIONS', 'REACTIONS', 'REBLOGS', 'MEDIA'].includes(type)) {
const { state } = history.location;
if (state && (state as any).soapboxModalKey === modalHistoryKey.current) {
history.goBack();
}
}
};
const ensureHistoryBuffer = () => {
@ -221,7 +221,7 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
ensureHistoryBuffer();
}
});
}, [children]);
if (!visible) {
return (

Wyświetl plik

@ -52,7 +52,7 @@ const Account: React.FC<IAccount> = ({ composeId, accountId, author }) => {
return (
<HStack space={1} alignItems='center' justifyContent='between' className='p-2.5'>
<div className='w-full'>
<AccountComponent account={account} withRelationship={false} />
<AccountComponent account={account} withRelationship={false} withLinkToProfile={false} />
</div>
{!author && button}
</HStack>

Wyświetl plik

@ -9,6 +9,7 @@ import Icon from 'soapbox/components/icon';
import IconButton from 'soapbox/components/icon-button';
import Audio from 'soapbox/features/audio';
import Video from 'soapbox/features/video';
import { useAppDispatch } from 'soapbox/hooks';
import ImageLoader from '../image-loader';
@ -39,6 +40,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
const intl = useIntl();
const history = useHistory();
const dispatch = useAppDispatch();
const [index, setIndex] = useState<number | null>(null);
const [navigationHidden, setNavigationHidden] = useState(false);
@ -94,8 +96,14 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
const handleStatusClick: React.MouseEventHandler = e => {
if (status && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
history.push(`/@${status.getIn(['account', 'acct'])}/posts/${status?.id}`);
dispatch((_, getState) => {
const account = typeof status.account === 'string' ? getState().accounts.get(status.account) : status.account;
if (!account) return;
history.push(`/@${account.acct}/posts/${status?.id}`);
onClose();
});
}
};