Skip to content

Commit

Permalink
Fix link handling within detailed status contents
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Sep 12, 2024
1 parent 4050beb commit 427ed60
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { getHashtagBarForStatus } from 'flavours/glitch/components/hashtag_bar';
import { IconLogo } from 'flavours/glitch/components/logo';
import { Permalink } from 'flavours/glitch/components/permalink';
import PictureInPicturePlaceholder from 'flavours/glitch/components/picture_in_picture_placeholder';
import { useAppHistory } from 'flavours/glitch/components/router';
import { VisibilityIcon } from 'flavours/glitch/components/visibility_icon';
import { useAppSelector } from 'flavours/glitch/store';

Expand Down Expand Up @@ -71,6 +72,7 @@ export const DetailedStatus: React.FC<{
const properStatus = status?.get('reblog') ?? status;
const [height, setHeight] = useState(0);
const nodeRef = useRef<HTMLDivElement>();
const history = useAppHistory();

const rewriteMentions = useAppSelector(
(state) => state.local_settings.get('rewrite_mentions', false) as boolean,
Expand Down Expand Up @@ -137,6 +139,18 @@ export const DetailedStatus: React.FC<{
if (onTranslate) onTranslate(status);
}, [onTranslate, status]);

const parseClick = useCallback(
(e: React.MouseEvent, destination: string) => {
if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey)) {
e.preventDefault();
history.push(destination);
}

e.stopPropagation();
},
[history],
);

if (!properStatus) {
return null;
}
Expand Down Expand Up @@ -354,7 +368,6 @@ export const DetailedStatus: React.FC<{
)}
</Permalink>

{/* TODO: parseClick={this.parseClick} */}
<StatusContent
status={status}
media={contentMedia}
Expand All @@ -367,6 +380,7 @@ export const DetailedStatus: React.FC<{
onUpdate={handleChildUpdate}
tagLinks={tagMisleadingLinks}
rewriteMentions={rewriteMentions}
parseClick={parseClick}
{...(statusContentProps as any)}
/>

Expand Down

0 comments on commit 427ed60

Please sign in to comment.