tutu/src/masto/acct.ts

24 lines
646 B
TypeScript
Raw Normal View History

2024-07-14 20:28:44 +08:00
import { Accessor, createResource } from "solid-js";
import type { mastodon } from "masto";
2024-07-22 21:57:04 +08:00
import { useSessions } from "./clients";
import { updateAcctInf } from "../accounts/stores";
2024-07-14 20:28:44 +08:00
2024-07-22 21:57:04 +08:00
export function useSignedInProfiles() {
const sessions = useSessions();
const [accessor, tools] = createResource(sessions, async (all) => {
return Promise.all(
all.map(async (x, i) => ({ ...x, inf: await updateAcctInf(i) })),
);
});
return [
() => {
2024-08-12 21:55:26 +08:00
const value = accessor();
if (!value) {
2024-07-22 21:57:04 +08:00
return sessions().map((x) => ({ ...x, inf: x.account.inf }));
}
2024-08-12 21:55:26 +08:00
return value;
2024-07-22 21:57:04 +08:00
},
tools,
] as const;
2024-07-14 20:28:44 +08:00
}