From e0d1136230b6643795b983080405800500829281 Mon Sep 17 00:00:00 2001 From: thislight Date: Sat, 28 Sep 2024 15:15:06 +0800 Subject: [PATCH] added composing new toots --- src/timelines/Home.tsx | 23 ++++++++-- src/timelines/TootBottomSheet.tsx | 4 +- .../{ReplyEditor.tsx => TootComposer.tsx} | 43 +++++++++++++++---- 3 files changed, 55 insertions(+), 15 deletions(-) rename src/timelines/{ReplyEditor.tsx => TootComposer.tsx} (90%) diff --git a/src/timelines/Home.tsx b/src/timelines/Home.tsx index b83de4d..259473b 100644 --- a/src/timelines/Home.tsx +++ b/src/timelines/Home.tsx @@ -11,7 +11,7 @@ import { Suspense, Match, Switch as JsSwitch, - ErrorBoundary + ErrorBoundary, } from "solid-js"; import { useDocumentTitle } from "../utils"; import { type mastodon } from "masto"; @@ -47,6 +47,7 @@ import { HeroSourceProvider, type HeroSource } from "../platform/anim"; import { useNavigate } from "@solidjs/router"; import { useSignedInProfiles } from "../masto/acct"; import { setCache as setTootBottomSheetCache } from "./TootBottomSheet"; +import TootComposer from "./TootComposer"; const TimelinePanel: Component<{ client: mastodon.rest.Client; @@ -72,6 +73,7 @@ const TimelinePanel: Component<{ { fullRefresh: props.fullRefetch }, ); const [expandedThreadId, setExpandedThreadId] = createSignal(); + const [typing, setTyping] = createSignal(false); const tlEndObserver = new IntersectionObserver(() => { if (untrack(() => props.prefetch) && !snapshot.loading) @@ -126,9 +128,11 @@ const TimelinePanel: Component<{ }; return ( - { - return

Oops: {String(err)}

- }}> + { + return

Oops: {String(err)}

; + }} + > + + refetchTimeline({direction: "new"})} + /> + {(item, index) => { let element: HTMLElement | undefined; diff --git a/src/timelines/TootBottomSheet.tsx b/src/timelines/TootBottomSheet.tsx index ae36ce9..06ab2c2 100644 --- a/src/timelines/TootBottomSheet.tsx +++ b/src/timelines/TootBottomSheet.tsx @@ -23,7 +23,7 @@ import cards from "../material/cards.module.css"; import { css } from "solid-styled"; import { vibrate } from "../platform/hardware"; import { createTimeSource, TimeSourceProvider } from "../platform/timesrc"; -import ReplyEditor from "./ReplyEditor"; +import TootComposer from "./TootComposer"; let cachedEntry: [string, mastodon.v1.Status] | undefined; @@ -250,7 +250,7 @@ const TootBottomSheet: Component = (props) => { - ( + rn: number, + K: T, +): T extends Array ? E : never { + const idx = Math.round(rn * K.length); + return K[idx]; +} + +const TootComposer: Component<{ + ref?: Ref; + style?: JSX.CSSProperties; + profile?: Account; + replyToDisplayName?: string; mentions?: readonly string[]; isTyping?: boolean; onTypingChange: (value: boolean) => void; client?: mastodon.rest.Client; inReplyToId?: string; onSent?: (status: mastodon.v1.Status) => void; + inputProps?: JSX.TextareaHTMLAttributes; }> = (props) => { let inputRef: HTMLTextAreaElement; let sendKey: string | undefined; @@ -223,6 +236,7 @@ const ReplyEditor: Component<{ top: "var(--scaffold-topbar-height, 0)", bottom: "var(--safe-area-inset-bottom, 0)", "z-index": 2, + ...props.style, } : undefined; @@ -274,20 +288,31 @@ const ReplyEditor: Component<{ return (
inputRef.focus()} >
- + + +