From 295a905b8b97d296776b4ba55939f2f5a2b99614 Mon Sep 17 00:00:00 2001 From: thislight Date: Sat, 12 Oct 2024 19:48:34 +0800 Subject: [PATCH] adjust thread visual --- src/masto/timelines.ts | 3 +- src/timelines/Home.tsx | 4 +- src/timelines/RegularToot.tsx | 84 ++++++++++++++++++++++++++---- src/timelines/Thread.tsx | 90 ++++++++++++++++----------------- src/timelines/TimelinePanel.tsx | 14 ++--- 5 files changed, 131 insertions(+), 64 deletions(-) diff --git a/src/masto/timelines.ts b/src/masto/timelines.ts index 06471df..37383e9 100644 --- a/src/masto/timelines.ts +++ b/src/masto/timelines.ts @@ -190,7 +190,7 @@ function checkOrCreatePager( newDirection: TimelineFetchDirection, ) { if (!lastPager) { - return timeline.list({ }).setDirection(newDirection); + return timeline.list({}).setDirection(newDirection); } else { let pager = lastPager; if (pager.getDirection() !== newDirection) { @@ -261,6 +261,7 @@ export function createTimeline( if (!chk) { return; } + console.debug("fetched chunk", chk); batch(() => { diff --git a/src/timelines/Home.tsx b/src/timelines/Home.tsx index 49119da..91ba685 100644 --- a/src/timelines/Home.tsx +++ b/src/timelines/Home.tsx @@ -270,7 +270,9 @@ const Home: ParentComponent = (props) => { - {child()} + navigate(-1)}> + {child()} + diff --git a/src/timelines/RegularToot.tsx b/src/timelines/RegularToot.tsx index 1c9eb60..2042618 100644 --- a/src/timelines/RegularToot.tsx +++ b/src/timelines/RegularToot.tsx @@ -111,13 +111,17 @@ type TootActionGroupProps = { onRetoot?: (value: T) => void; onFavourite?: (value: T) => void; onBookmark?: (value: T) => void; - onReply?: (value: T) => void; + onReply?: ( + value: T, + event: MouseEvent & { currentTarget: HTMLButtonElement }, + ) => void; }; type TootCardProps = { status: mastodon.v1.Status; actionable?: boolean; evaluated?: boolean; + thread?: "top" | "bottom" | "middle"; } & TootActionGroupProps & JSX.HTMLElementTags["article"]; @@ -125,19 +129,40 @@ function isolatedCallback(e: MouseEvent) { e.stopPropagation(); } +export function findRootToot(element: HTMLElement) { + let current: HTMLElement | null = element; + while (current && !current.classList.contains(tootStyle.toot)) { + current = current.parentElement; + } + if (!current) { + throw Error( + `the element must be placed under a element with ${tootStyle.toot}`, + ); + } + return current; +} + function TootActionGroup( props: TootActionGroupProps & { value: T }, ) { + let actGrpElement: HTMLDivElement; const toot = () => props.value; return ( -
- +
+ + + +