Skip to content

Commit

Permalink
Refactor status handleClick and handleHotkeyOpen handlers (mastod…
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored Jan 3, 2025
1 parent af7d6e5 commit 9712518
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/javascript/mastodon/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ class Status extends ImmutablePureComponent {

handleClick = e => {
e.preventDefault();
this.handleHotkeyOpen(e);

if (e?.button === 0 && !(e?.ctrlKey || e?.metaKey)) {
this._openStatus();
} else if (e?.button === 1 || (e?.button === 0 && (e?.ctrlKey || e?.metaKey))) {
this._openStatus(true);
}
};

handleMouseUp = e => {
Expand Down Expand Up @@ -275,7 +280,11 @@ class Status extends ImmutablePureComponent {
this.props.onMention(this._properStatus().get('account'));
};

handleHotkeyOpen = (e) => {
handleHotkeyOpen = () => {
this._openStatus();
};

_openStatus = (newTab = false) => {
if (this.props.onClick) {
this.props.onClick();
return;
Expand All @@ -290,7 +299,7 @@ class Status extends ImmutablePureComponent {

const path = `/@${status.getIn(['account', 'acct'])}/${status.get('id')}`;

if (e?.button === 1 || (e?.button === 0 && (e?.ctrlKey || e?.metaKey))) {
if (newTab) {
window.open(path, '_blank', 'noopener');
} else {
history.push(path);
Expand Down

0 comments on commit 9712518

Please sign in to comment.