TootBottomSheet: fix main toot not links profile
All checks were successful
/ depoly (push) Successful in 2m55s

This commit is contained in:
thislight 2024-10-30 20:58:36 +08:00
parent 31b27237cd
commit f4c0104d48
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
7 changed files with 179 additions and 150 deletions

View file

@ -9,28 +9,12 @@ import {
import { type mastodon } from "masto";
import { vibrate } from "../platform/hardware";
import Thread from "./Thread.jsx";
import { makeAcctText, useDefaultSession } from "../masto/clients";
import { useDefaultSession } from "../masto/clients";
import { useHeroSource } from "../platform/anim";
import { HERO as BOTTOM_SHEET_HERO } from "../material/BottomSheet";
import { setCache as setTootBottomSheetCache } from "./TootBottomSheet";
import { useNavigate } from "@solidjs/router";
/**
* find bottom-to-top the element with `data-rel`.
*/
function findElementActionable(
element: HTMLElement,
top: HTMLElement,
): HTMLElement | undefined {
let current = element;
while (!current.dataset.rel) {
if (!current.parentElement || current.parentElement === top) {
return undefined;
}
current = current.parentElement;
}
return current;
}
import { findElementActionable } from "./RegularToot";
const TootList: Component<{
ref?: Ref<HTMLDivElement>;
@ -116,8 +100,8 @@ const TootList: Component<{
event.currentTarget,
);
if (actionableElement) {
if (actionableElement.dataset.rel === "acct") {
if (actionableElement && checkIsExpended(status)) {
if (actionableElement.dataset.action === "acct") {
event.stopPropagation();
const target = actionableElement as HTMLAnchorElement;
@ -127,15 +111,18 @@ const TootList: Component<{
`@${new URL(target.href).origin}`);
navigate(`/${acct}/profile/${target.dataset.acctId}`);
return;
} else {
console.warn("unknown action", actionableElement.dataset.rel);
}
}
// else if (!actionableElement || !checkIsExpended(status) || <rel is not one of known action>)
if (status.id !== expandedThreadId()) {
setExpandedThreadId((x) => (x ? undefined : status.id));
} else {
if (status.id !== expandedThreadId()) {
setExpandedThreadId((x) => (x ? undefined : status.id));
} else {
openFullScreenToot(status, event.currentTarget as HTMLElement);
}
openFullScreenToot(status, event.currentTarget as HTMLElement);
}
};