TootList: support openFullScreenToot
This commit is contained in:
parent
664c1568d0
commit
7e120fba2d
1 changed files with 37 additions and 2 deletions
|
@ -18,6 +18,10 @@ import PullDownToRefresh from "./PullDownToRefresh";
|
||||||
import TootComposer from "./TootComposer";
|
import TootComposer from "./TootComposer";
|
||||||
import Thread from "./Thread.jsx";
|
import Thread from "./Thread.jsx";
|
||||||
import { useDefaultSession } from "../masto/clients";
|
import { useDefaultSession } from "../masto/clients";
|
||||||
|
import { useHeroSignal } from "../platform/anim";
|
||||||
|
import { HERO as BOTTOM_SHEET_HERO } from "../material/BottomSheet";
|
||||||
|
import { setCache as setTootBottomSheetCache } from "./TootBottomSheet";
|
||||||
|
import { useNavigate } from "@solidjs/router";
|
||||||
|
|
||||||
const TootList: Component<{
|
const TootList: Component<{
|
||||||
ref?: Ref<HTMLDivElement>;
|
ref?: Ref<HTMLDivElement>;
|
||||||
|
@ -26,7 +30,9 @@ const TootList: Component<{
|
||||||
onChangeToot: (id: string, value: mastodon.v1.Status) => void;
|
onChangeToot: (id: string, value: mastodon.v1.Status) => void;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
const session = useDefaultSession();
|
const session = useDefaultSession();
|
||||||
|
const [, setHeroSrc] = useHeroSignal(BOTTOM_SHEET_HERO);
|
||||||
const [expandedThreadId, setExpandedThreadId] = createSignal<string>();
|
const [expandedThreadId, setExpandedThreadId] = createSignal<string>();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const onBookmark = async (
|
const onBookmark = async (
|
||||||
client: mastodon.rest.Client,
|
client: mastodon.rest.Client,
|
||||||
|
@ -65,6 +71,30 @@ const TootList: Component<{
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openFullScreenToot = (
|
||||||
|
toot: mastodon.v1.Status,
|
||||||
|
srcElement?: HTMLElement,
|
||||||
|
reply?: boolean,
|
||||||
|
) => {
|
||||||
|
const p = session()?.account;
|
||||||
|
if (!p) return;
|
||||||
|
const inf = p.inf;
|
||||||
|
if (!inf) {
|
||||||
|
console.warn("no account info?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setHeroSrc(srcElement);
|
||||||
|
const acct = `${inf.username}@${p.site}`;
|
||||||
|
setTootBottomSheetCache(acct, toot);
|
||||||
|
navigate(`/${encodeURIComponent(acct)}/toot/${toot.id}`, {
|
||||||
|
state: reply
|
||||||
|
? {
|
||||||
|
tootReply: true,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary
|
<ErrorBoundary
|
||||||
fallback={(err, reset) => {
|
fallback={(err, reset) => {
|
||||||
|
@ -82,14 +112,19 @@ const TootList: Component<{
|
||||||
toots={toots}
|
toots={toots}
|
||||||
onBoost={onBoost}
|
onBoost={onBoost}
|
||||||
onBookmark={onBookmark}
|
onBookmark={onBookmark}
|
||||||
onReply={({ status }, element) => {}}
|
onReply={({ status }, element) =>
|
||||||
|
openFullScreenToot(status, element, true)
|
||||||
|
}
|
||||||
client={session()?.client!}
|
client={session()?.client!}
|
||||||
isExpended={(status) => status.id === expandedThreadId()}
|
isExpended={(status) => status.id === expandedThreadId()}
|
||||||
onItemClick={(status, event) => {
|
onItemClick={(status, event) => {
|
||||||
if (status.id !== expandedThreadId()) {
|
if (status.id !== expandedThreadId()) {
|
||||||
setExpandedThreadId((x) => (x ? undefined : status.id));
|
setExpandedThreadId((x) => (x ? undefined : status.id));
|
||||||
} else {
|
} else {
|
||||||
// TODO: open full-screen toot
|
openFullScreenToot(
|
||||||
|
status,
|
||||||
|
event.currentTarget as HTMLElement,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue