From 05b44067c2201493de9e01ae9d13c56ae00ad1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Thu, 5 Mar 2026 10:54:38 +0100 Subject: [PATCH] nicolium: apply this hotkey thing to new timeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/nicolium/src/columns/timeline.tsx | 6 ++---- packages/nicolium/src/components/statuses/status.tsx | 6 ++++-- packages/nicolium/src/components/statuses/tombstone.tsx | 4 ++-- packages/nicolium/src/utils/scroll-utils.ts | 3 +++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/nicolium/src/columns/timeline.tsx b/packages/nicolium/src/columns/timeline.tsx index edea4b39c..752e5aa3f 100644 --- a/packages/nicolium/src/columns/timeline.tsx +++ b/packages/nicolium/src/columns/timeline.tsx @@ -106,18 +106,16 @@ const Timeline: React.FC = ({ query, contextType = 'public' }) => { const { entries, queuedCount, fetchNextPage, dequeueEntries, isFetching, isPending } = query; - const handleMoveUp = (index: number) => { + const handleMoveUp = (index: number) => selectChild(index - 1, node, document.getElementById('status-list') ?? undefined); - }; - const handleMoveDown = (index: number) => { + const handleMoveDown = (index: number) => selectChild( index + 1, node, document.getElementById('status-list') ?? undefined, entries.length, ); - }; const renderEntry = (entry: TimelineEntry, index: number) => { if (entry.type === 'status') { diff --git a/packages/nicolium/src/components/statuses/status.tsx b/packages/nicolium/src/components/statuses/status.tsx index e3fe97789..721719695 100644 --- a/packages/nicolium/src/components/statuses/status.tsx +++ b/packages/nicolium/src/components/statuses/status.tsx @@ -330,14 +330,16 @@ const Status: React.FC = React.memo((props) => { const handleHotkeyMoveUp = () => { if (onMoveUp) { - onMoveUp(status.id, featured); + return onMoveUp(status.id, featured); } + return false; }; const handleHotkeyMoveDown = () => { if (onMoveDown) { - onMoveDown(status.id, featured); + return onMoveDown(status.id, featured); } + return false; }; const handleHotkeyToggleSensitive = () => { diff --git a/packages/nicolium/src/components/statuses/tombstone.tsx b/packages/nicolium/src/components/statuses/tombstone.tsx index 702b63893..cf52fcf49 100644 --- a/packages/nicolium/src/components/statuses/tombstone.tsx +++ b/packages/nicolium/src/components/statuses/tombstone.tsx @@ -6,8 +6,8 @@ import { Hotkeys } from '@/features/ui/components/hotkeys'; interface ITombstone { id: string; - onMoveUp?: (statusId: string) => void; - onMoveDown?: (statusId: string) => void; + onMoveUp?: (statusId: string) => void | boolean; + onMoveDown?: (statusId: string) => void | boolean; deleted?: boolean; } diff --git a/packages/nicolium/src/utils/scroll-utils.ts b/packages/nicolium/src/utils/scroll-utils.ts index c13159596..fcfa39b2e 100644 --- a/packages/nicolium/src/utils/scroll-utils.ts +++ b/packages/nicolium/src/utils/scroll-utils.ts @@ -8,12 +8,15 @@ const selectChild = ( count?: number, align?: 'start' | 'center' | 'end', ) => { + if (index < 0) return false; + if (count !== undefined && index === count) { const loadMoreButton = node.querySelector('.⁂-load-more'); if (loadMoreButton) { loadMoreButton.focus({ preventScroll: false }); return; } + return false; } const selector = `[data-index="${index}"] .focusable`;