From d4cc2ab29b472771e7df55d2aa641a391844f46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 4 Jun 2022 15:20:19 +0200 Subject: [PATCH] Focus on selected status in status list, add moveUp/moveDown hotkeys to tombstone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../components/status-reply-mentions.tsx | 19 +++++++------- app/soapbox/components/tombstone.tsx | 26 ++++++++++++++----- app/soapbox/features/status/index.tsx | 9 ++++++- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/app/soapbox/components/status-reply-mentions.tsx b/app/soapbox/components/status-reply-mentions.tsx index 955924acc..9f8d890ae 100644 --- a/app/soapbox/components/status-reply-mentions.tsx +++ b/app/soapbox/components/status-reply-mentions.tsx @@ -1,4 +1,3 @@ -import { List as ImmutableList } from 'immutable'; import React from 'react'; import { FormattedList, FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; @@ -7,7 +6,7 @@ import { openModal } from 'soapbox/actions/modals'; import HoverRefWrapper from 'soapbox/components/hover_ref_wrapper'; import { useAppDispatch } from 'soapbox/hooks'; -import type { Status } from 'soapbox/types/entities'; +import type { Account, Status } from 'soapbox/types/entities'; interface IStatusReplyMentions { status: Status, @@ -19,17 +18,19 @@ const StatusReplyMentions: React.FC = ({ status }) => { const handleOpenMentionsModal: React.MouseEventHandler = (e) => { e.stopPropagation(); + const account = status.account as Account; + dispatch(openModal('MENTIONS', { - username: status.getIn(['account', 'acct']), - statusId: status.get('id'), + username: account.acct, + statusId: status.id, })); }; - if (!status.get('in_reply_to_id')) { + if (!status.in_reply_to_id) { return null; } - const to = status.get('mentions', ImmutableList()); + const to = status.mentions; // The post is a reply, but it has no mentions. // Rare, but it can happen. @@ -46,14 +47,14 @@ const StatusReplyMentions: React.FC = ({ status }) => { // The typical case with a reply-to and a list of mentions. const accounts = to.slice(0, 2).map(account => ( - - @{account.get('username')} + + @{account.username} )).toArray(); if (to.size > 2) { accounts.push( - + , ); diff --git a/app/soapbox/components/tombstone.tsx b/app/soapbox/components/tombstone.tsx index 672d1c5f6..e90125b39 100644 --- a/app/soapbox/components/tombstone.tsx +++ b/app/soapbox/components/tombstone.tsx @@ -1,16 +1,30 @@ import React from 'react'; +import { HotKeys } from 'react-hotkeys'; import { FormattedMessage } from 'react-intl'; import { Text } from 'soapbox/components/ui'; +interface ITombstone { + id: string, + onMoveUp: (statusId: string) => void, + onMoveDown: (statusId: string) => void, +} + /** Represents a deleted item. */ -const Tombstone: React.FC = () => { +const Tombstone: React.FC = ({ id, onMoveUp, onMoveDown }) => { + const handlers = { + moveUp: () => onMoveUp(id), + moveDown: () => onMoveDown(id), + }; + return ( -
- - - -
+ +
+ + + +
+
); }; diff --git a/app/soapbox/features/status/index.tsx b/app/soapbox/features/status/index.tsx index 9f0e3dbf6..8af71c530 100644 --- a/app/soapbox/features/status/index.tsx +++ b/app/soapbox/features/status/index.tsx @@ -561,7 +561,12 @@ class Status extends ImmutablePureComponent { renderTombstone(id: string) { return (
- +
); } @@ -635,6 +640,8 @@ class Status extends ImmutablePureComponent { index: this.props.ancestorsIds.size, offset: -80, }); + + setImmediate(() => this.status?.querySelector('a')?.focus()); } }