TootBottomSheet: added cache
This commit is contained in:
parent
c56c098bdb
commit
368bca9fa1
2 changed files with 20 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
import { useNavigate, useParams } from "@solidjs/router";
|
||||
import { createResource, Show, type Component } from "solid-js";
|
||||
import { createEffect, createResource, Show, type Component } from "solid-js";
|
||||
import Scaffold from "../material/Scaffold";
|
||||
import TootThread from "./TootThread";
|
||||
import { AppBar, IconButton, Toolbar } from "@suid/material";
|
||||
|
@ -9,13 +9,28 @@ import { isiOS } from "../platform/host";
|
|||
import { createUnauthorizedClient, useSessions } from "../masto/clients";
|
||||
import { resolveCustomEmoji } from "../masto/toot";
|
||||
import RegularToot from "./RegularToot";
|
||||
import type { mastodon } from "masto";
|
||||
|
||||
let cachedEntry: [string, mastodon.v1.Status] | undefined;
|
||||
|
||||
export function setCache(acct: string, status: mastodon.v1.Status) {
|
||||
cachedEntry = [acct, status]
|
||||
}
|
||||
|
||||
function getCache(acct: string, id: string) {
|
||||
if (acct === cachedEntry?.[0] && id === cachedEntry?.[1].id) {
|
||||
return cachedEntry[1]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const TootBottomSheet: Component = (props) => {
|
||||
const params = useParams<{ acct: string; id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const allSession = useSessions();
|
||||
const acctText = () => decodeURIComponent(params.acct)
|
||||
const session = () => {
|
||||
const [inputUsername, inputSite] = decodeURIComponent(params.acct).split(
|
||||
const [inputUsername, inputSite] = acctText().split(
|
||||
"@",
|
||||
2,
|
||||
);
|
||||
|
@ -34,7 +49,7 @@ const TootBottomSheet: Component = (props) => {
|
|||
},
|
||||
);
|
||||
|
||||
const toot = remoteToot;
|
||||
const toot = () => remoteToot() ?? getCache(acctText(), params.id);
|
||||
|
||||
const tootTitle = () => {
|
||||
const t = toot();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue