add useSessionForAcctStr

This commit is contained in:
thislight 2024-10-18 11:58:17 +08:00
parent 040016ddce
commit 657c886fab
No known key found for this signature in database
GPG key ID: A50F9451AC56A63E
2 changed files with 39 additions and 16 deletions

View file

@ -15,7 +15,7 @@ import {
ArrowBack as BackIcon,
Close as CloseIcon,
} from "@suid/icons-material";
import { createUnauthorizedClient, useSessions } from "../masto/clients";
import { useSessionForAcctStr } from "../masto/clients";
import { resolveCustomEmoji } from "../masto/toot";
import RegularToot from "./RegularToot";
import type { mastodon } from "masto";
@ -45,24 +45,10 @@ const TootBottomSheet: Component = (props) => {
tootReply?: boolean;
}>();
const navigate = useNavigate();
const allSession = useSessions();
const time = createTimeSource();
const [isInTyping, setInTyping] = createSignal(false);
const acctText = () => decodeURIComponent(params.acct);
const session = () => {
const [inputUsername, inputSite] = acctText().split("@", 2);
const authedSession = allSession().find(
(x) =>
x.account.site === inputSite &&
x.account.inf?.username === inputUsername,
);
return (
authedSession ?? {
client: createUnauthorizedClient(inputSite),
account: undefined,
}
);
};
const session = useSessionForAcctStr(acctText)
const pushedCount = () => {
return location.state?.tootBottomSheetPushedCount || 0;