From 5db1bbef69643fc6f18f85bb0415cf68e6f9a088 Mon Sep 17 00:00:00 2001 From: diondiondion Date: Thu, 28 Aug 2025 14:33:23 +0200 Subject: [PATCH] [Glitch] Add hotkey Q for quoting the currently focused post Port 229cbc6a2495fa01780b75f4b2a80dc099fb5d5c to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/components/hotkeys/index.tsx | 1 + app/javascript/flavours/glitch/components/status.jsx | 6 ++++++ .../flavours/glitch/components/status/reblog_button.tsx | 6 +++++- .../flavours/glitch/containers/status_container.js | 8 ++++++++ .../flavours/glitch/features/keyboard_shortcuts/index.jsx | 7 +++++++ app/javascript/flavours/glitch/features/status/index.jsx | 6 ++++++ 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/components/hotkeys/index.tsx b/app/javascript/flavours/glitch/components/hotkeys/index.tsx index 33d11dab92..b1484ec3ac 100644 --- a/app/javascript/flavours/glitch/components/hotkeys/index.tsx +++ b/app/javascript/flavours/glitch/components/hotkeys/index.tsx @@ -105,6 +105,7 @@ const hotkeyMatcherMap = { reply: just('r'), favourite: just('f'), boost: just('b'), + quote: just('q'), mention: just('m'), open: any('enter', 'o'), openProfile: just('p'), diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index 3bdc72311d..c034ae84e8 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -95,6 +95,7 @@ class Status extends ImmutablePureComponent { onReply: PropTypes.func, onFavourite: PropTypes.func, onReblog: PropTypes.func, + onQuote: PropTypes.func, onBookmark: PropTypes.func, onDelete: PropTypes.func, onDirect: PropTypes.func, @@ -359,6 +360,10 @@ class Status extends ImmutablePureComponent { this.props.onBookmark(this.props.status, e); }; + handleHotkeyQuote = () => { + this.props.onQuote(this._properStatus()); + }; + handleHotkeyMention = e => { e.preventDefault(); this.props.onMention(this.props.status.get('account')); @@ -479,6 +484,7 @@ class Status extends ImmutablePureComponent { reply: this.handleHotkeyReply, favourite: this.handleHotkeyFavourite, boost: this.handleHotkeyBoost, + quote: this.handleHotkeyQuote, mention: this.handleHotkeyMention, open: this.handleHotkeyOpen, openProfile: this.handleHotkeyOpenProfile, diff --git a/app/javascript/flavours/glitch/components/status/reblog_button.tsx b/app/javascript/flavours/glitch/components/status/reblog_button.tsx index f7a0f6691c..98253143e3 100644 --- a/app/javascript/flavours/glitch/components/status/reblog_button.tsx +++ b/app/javascript/flavours/glitch/components/status/reblog_button.tsx @@ -59,6 +59,10 @@ const messages = defineMessages({ defaultMessage: 'Private posts cannot be quoted', }, reblog: { id: 'status.reblog', defaultMessage: 'Boost' }, + reblog_or_quote: { + id: 'status.reblog_or_quote', + defaultMessage: 'Boost or quote', + }, reblog_cancel: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost', @@ -176,7 +180,7 @@ export const StatusReblogButton: FC = ({ > ({ } }); }, + + onQuote (status) { + if (isFeatureEnabled('outgoing_quotes')) { + dispatch(quoteComposeById(status.get('id'))); + } + }, onReblog (status, e) { dispatch(toggleReblog(status.get('id'), e.shiftKey)); diff --git a/app/javascript/flavours/glitch/features/keyboard_shortcuts/index.jsx b/app/javascript/flavours/glitch/features/keyboard_shortcuts/index.jsx index 05e0167870..1794aa9a24 100644 --- a/app/javascript/flavours/glitch/features/keyboard_shortcuts/index.jsx +++ b/app/javascript/flavours/glitch/features/keyboard_shortcuts/index.jsx @@ -9,6 +9,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import InfoIcon from '@/material-icons/400-24px/info.svg?react'; import Column from 'flavours/glitch/components/column'; import ColumnHeader from 'flavours/glitch/components/column_header'; +import { isFeatureEnabled } from 'flavours/glitch/utils/environment'; const messages = defineMessages({ heading: { id: 'keyboard_shortcuts.heading', defaultMessage: 'Keyboard Shortcuts' }, @@ -62,6 +63,12 @@ class KeyboardShortcuts extends ImmutablePureComponent { b + {isFeatureEnabled('outgoing_quotes') && ( + + q + + + )} d diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index db62c2b55b..fbd24bcf4a 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -63,6 +63,7 @@ import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from import ActionBar from './components/action_bar'; import { DetailedStatus } from './components/detailed_status'; import { RefreshController } from './components/refresh_controller'; +import { quoteComposeById } from '@/flavours/glitch/actions/compose_typed'; const messages = defineMessages({ revealAll: { id: 'status.show_more_all', defaultMessage: 'Show more for all' }, @@ -429,6 +430,10 @@ class Status extends ImmutablePureComponent { this.handleBookmarkClick(this.props.status); }; + handleHotkeyQuote = () => { + this.props.dispatch(quoteComposeById(this.props.status.get('id'))); + }; + handleHotkeyMention = e => { e.preventDefault(); this.handleMentionClick(this.props.status); @@ -573,6 +578,7 @@ class Status extends ImmutablePureComponent { reply: this.handleHotkeyReply, favourite: this.handleHotkeyFavourite, boost: this.handleHotkeyBoost, + quote: this.handleHotkeyQuote, bookmark: this.handleHotkeyBookmark, mention: this.handleHotkeyMention, openProfile: this.handleHotkeyOpenProfile,