Skip to content

Commit

Permalink
[Glitch] Change to treat the url to a post already owned as an intern…
Browse files Browse the repository at this point in the history
…al link
  • Loading branch information
atsu1125 committed Oct 9, 2022
1 parent d3110ff commit 9a2e1fc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/javascript/flavours/glitch/components/status_content.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
import Permalink from './permalink';
import classnames from 'classnames';
import Icon from 'flavours/glitch/components/icon';
import { autoPlayGif } from 'flavours/glitch/util/initial_state';
import { decode as decodeIDNA } from 'flavours/glitch/util/idna';

const messages = defineMessages({
postByAcct: { id: 'status.post_by_acct', defaultMessage: 'Post by @{acct}' },
});

const textMatchesTarget = (text, origin, host) => {
return (text === origin || text === host
|| text.startsWith(origin + '/') || text.startsWith(host + '/')
Expand Down Expand Up @@ -62,6 +66,7 @@ const isLinkMisleading = (link) => {
return !(textMatchesTarget(text, origin, host) || textMatchesTarget(text.toLowerCase(), origin, host));
};

@injectIntl
export default class StatusContent extends React.PureComponent {

static propTypes = {
Expand All @@ -76,6 +81,7 @@ export default class StatusContent extends React.PureComponent {
onUpdate: PropTypes.func,
tagLinks: PropTypes.bool,
rewriteMentions: PropTypes.string,
intl: PropTypes.object.isRequired,
};

static defaultProps = {
Expand Down Expand Up @@ -118,6 +124,9 @@ export default class StatusContent extends React.PureComponent {
}
} else if (link.textContent[0] === '#' || (link.previousSibling && link.previousSibling.textContent && link.previousSibling.textContent[link.previousSibling.textContent.length - 1] === '#')) {
link.addEventListener('click', this.onHashtagClick.bind(this, link.text), false);
} else if (link.classList.contains('status-url-link')) {
link.setAttribute('title', this.props.intl.formatMessage(messages.postByAcct, { acct: link.dataset.statusAccountAcct }));
link.addEventListener('click', this.onStatusUrlClick.bind(this, link.dataset.statusId), false);
} else {
link.addEventListener('click', this.onLinkClick.bind(this), false);
link.setAttribute('title', link.href);
Expand Down Expand Up @@ -209,6 +218,12 @@ export default class StatusContent extends React.PureComponent {
}
}

onStatusUrlClick = (statusId, e) => {
if (this.props.parseClick) {
this.props.parseClick(e, `/statuses/${statusId}`);
}
}

handleMouseDown = (e) => {
this.startXY = [e.clientX, e.clientY];
}
Expand Down

0 comments on commit 9a2e1fc

Please sign in to comment.