Merge branch 'modals-fix' into 'develop'
Fix links in modals Closes #1240 See merge request soapbox-pub/soapbox!1974
This commit is contained in:
commit
ad1e58c95c
7 changed files with 34 additions and 17 deletions
|
@ -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.
|
- Posts: fix monospace font in Markdown code blocks.
|
||||||
- Modals: fix action buttons overflow
|
- Modals: fix action buttons overflow
|
||||||
- Editing: don't insert edited posts to the top of the feed.
|
- 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
|
## [3.0.0] - 2022-12-25
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,17 @@ import type { Account as AccountEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
interface IInstanceFavicon {
|
interface IInstanceFavicon {
|
||||||
account: AccountEntity,
|
account: AccountEntity,
|
||||||
|
disabled?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
const InstanceFavicon: React.FC<IInstanceFavicon> = ({ account }) => {
|
const InstanceFavicon: React.FC<IInstanceFavicon> = ({ account, disabled }) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const handleClick: React.MouseEventHandler = (e) => {
|
const handleClick: React.MouseEventHandler = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
if (disabled) return;
|
||||||
|
|
||||||
const timelineUrl = `/timeline/${account.domain}`;
|
const timelineUrl = `/timeline/${account.domain}`;
|
||||||
if (!(e.ctrlKey || e.metaKey)) {
|
if (!(e.ctrlKey || e.metaKey)) {
|
||||||
history.push(timelineUrl);
|
history.push(timelineUrl);
|
||||||
|
@ -32,7 +35,11 @@ const InstanceFavicon: React.FC<IInstanceFavicon> = ({ account }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
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' />
|
<img src={account.favicon} alt='' title={account.domain} className='w-full max-h-full' />
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
@ -219,7 +226,7 @@ const Account = ({
|
||||||
<Text theme='muted' size='sm' direction='ltr' truncate>@{username}</Text>
|
<Text theme='muted' size='sm' direction='ltr' truncate>@{username}</Text>
|
||||||
|
|
||||||
{account.favicon && (
|
{account.favicon && (
|
||||||
<InstanceFavicon account={account} />
|
<InstanceFavicon account={account} disabled={!withLinkToProfile} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(timestamp) ? (
|
{(timestamp) ? (
|
||||||
|
|
|
@ -152,8 +152,10 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
|
||||||
|
|
||||||
const handleModalOpen = () => {
|
const handleModalOpen = () => {
|
||||||
modalHistoryKey.current = Date.now();
|
modalHistoryKey.current = Date.now();
|
||||||
unlistenHistory.current = history.listen((_, action) => {
|
unlistenHistory.current = history.listen(({ state }, action) => {
|
||||||
if (action === 'POP') {
|
if (!(state as any)?.soapboxModalKey) {
|
||||||
|
onClose();
|
||||||
|
} else if (action === 'POP') {
|
||||||
handleOnClose();
|
handleOnClose();
|
||||||
|
|
||||||
if (onCancel) onCancel();
|
if (onCancel) onCancel();
|
||||||
|
@ -165,12 +167,10 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
|
||||||
if (unlistenHistory.current) {
|
if (unlistenHistory.current) {
|
||||||
unlistenHistory.current();
|
unlistenHistory.current();
|
||||||
}
|
}
|
||||||
if (!['FAVOURITES', 'MENTIONS', 'REACTIONS', 'REBLOGS', 'MEDIA'].includes(type)) {
|
|
||||||
const { state } = history.location;
|
const { state } = history.location;
|
||||||
if (state && (state as any).soapboxModalKey === modalHistoryKey.current) {
|
if (state && (state as any).soapboxModalKey === modalHistoryKey.current) {
|
||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ensureHistoryBuffer = () => {
|
const ensureHistoryBuffer = () => {
|
||||||
|
@ -221,7 +221,7 @@ const ModalRoot: React.FC<IModalRoot> = ({ children, onCancel, onClose, type })
|
||||||
|
|
||||||
ensureHistoryBuffer();
|
ensureHistoryBuffer();
|
||||||
}
|
}
|
||||||
});
|
}, [children]);
|
||||||
|
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -52,7 +52,7 @@ const Account: React.FC<IAccount> = ({ composeId, accountId, author }) => {
|
||||||
return (
|
return (
|
||||||
<HStack space={1} alignItems='center' justifyContent='between' className='p-2.5'>
|
<HStack space={1} alignItems='center' justifyContent='between' className='p-2.5'>
|
||||||
<div className='w-full'>
|
<div className='w-full'>
|
||||||
<AccountComponent account={account} withRelationship={false} />
|
<AccountComponent account={account} withRelationship={false} withLinkToProfile={false} />
|
||||||
</div>
|
</div>
|
||||||
{!author && button}
|
{!author && button}
|
||||||
</HStack>
|
</HStack>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import Icon from 'soapbox/components/icon';
|
||||||
import IconButton from 'soapbox/components/icon-button';
|
import IconButton from 'soapbox/components/icon-button';
|
||||||
import Audio from 'soapbox/features/audio';
|
import Audio from 'soapbox/features/audio';
|
||||||
import Video from 'soapbox/features/video';
|
import Video from 'soapbox/features/video';
|
||||||
|
import { useAppDispatch } from 'soapbox/hooks';
|
||||||
|
|
||||||
import ImageLoader from '../image-loader';
|
import ImageLoader from '../image-loader';
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const [index, setIndex] = useState<number | null>(null);
|
const [index, setIndex] = useState<number | null>(null);
|
||||||
const [navigationHidden, setNavigationHidden] = useState(false);
|
const [navigationHidden, setNavigationHidden] = useState(false);
|
||||||
|
@ -94,8 +96,14 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
const handleStatusClick: React.MouseEventHandler = e => {
|
const handleStatusClick: React.MouseEventHandler = e => {
|
||||||
if (status && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
if (status && e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
||||||
e.preventDefault();
|
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();
|
onClose();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue