From 678fc100c8d3715e2029d0a9baa0523902fcc126 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 5 Nov 2023 17:41:29 +0800 Subject: [PATCH] Allow shifts to open composer in new window --- src/components/compose-button.jsx | 1 - src/components/compose.jsx | 1 - src/components/status.jsx | 12 ++++++++++-- src/utils/open-compose.js | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/compose-button.jsx b/src/components/compose-button.jsx index ceb452c4..3587c2f6 100644 --- a/src/components/compose-button.jsx +++ b/src/components/compose-button.jsx @@ -11,7 +11,6 @@ export default function ComposeButton() { const newWin = openCompose(); if (!newWin) { - alert('Looks like your browser is blocking popups.'); states.showCompose = true; } } else { diff --git a/src/components/compose.jsx b/src/components/compose.jsx index f5d8a64a..18480db7 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -607,7 +607,6 @@ function Compose({ }); if (!newWin) { - alert('Looks like your browser is blocking popups.'); return; } diff --git a/src/components/status.jsx b/src/components/status.jsx index 67c94cea..a5ef587c 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -44,6 +44,7 @@ import htmlContentLength from '../utils/html-content-length'; import isMastodonLinkMaybe from '../utils/isMastodonLinkMaybe'; import localeMatch from '../utils/locale-match'; import niceDateTime from '../utils/nice-date-time'; +import openCompose from '../utils/open-compose'; import pmem from '../utils/pmem'; import safeBoundingBoxPadding from '../utils/safe-bounding-box-padding'; import shortenNumber from '../utils/shorten-number'; @@ -373,10 +374,17 @@ function Status({ canBoost = true; } - const replyStatus = () => { + const replyStatus = (e) => { if (!sameInstance || !authenticated) { return alert(unauthInteractionErrorMessage); } + // syntheticEvent comes from MenuItem + if (e?.shiftKey || e?.syntheticEvent?.shiftKey) { + const newWin = openCompose({ + replyToStatus: status, + }); + if (newWin) return; + } states.showCompose = { replyToStatus: status, }; @@ -855,7 +863,7 @@ function Status({ ); const hotkeysEnabled = !readOnly && !previewMode; - const rRef = useHotkeys('r', replyStatus, { + const rRef = useHotkeys('r, shift+r', replyStatus, { enabled: hotkeysEnabled, }); const fRef = useHotkeys( diff --git a/src/utils/open-compose.js b/src/utils/open-compose.js index da677112..b8192876 100644 --- a/src/utils/open-compose.js +++ b/src/utils/open-compose.js @@ -18,6 +18,8 @@ export default function openCompose(opts) { // } newWin.__COMPOSE__ = opts; + } else { + alert('Looks like your browser is blocking popups.'); } return newWin;