From 0327db3db0483ce055192c374d6a077522aff7a1 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 3 Jan 2025 23:00:52 +0100 Subject: [PATCH] [Glitch] Refactor status `handleClick` and `handleHotkeyOpen` handlers Port 9712518b2fb2585df3bcff95a687c291f04a4199 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/components/status.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index b38fac46fb..b220460ef1 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -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 => { @@ -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; @@ -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);