Skip to content

Commit

Permalink
[Glitch] Refactor status handleClick and handleHotkeyOpen handlers
Browse files Browse the repository at this point in the history
Port 9712518 to glitch-soc

Signed-off-by: Claire <[email protected]>
  • Loading branch information
ClearlyClaire committed Jan 4, 2025
1 parent d878ca2 commit 0327db3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/javascript/flavours/glitch/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,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 @@ -349,7 +354,11 @@ class Status extends ImmutablePureComponent {
this.props.onMention(this.props.status.get('account'));
};

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

_openStatus = (newTab = false) => {
if (this.props.onClick) {
this.props.onClick();
return;
Expand All @@ -364,7 +373,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 0327db3

Please sign in to comment.