28 lines
778 B
TypeScript
28 lines
778 B
TypeScript
import { Accessor, createResource } from "solid-js";
|
|
import type { mastodon } from "masto";
|
|
import { useSessions } from "./clients";
|
|
import { updateAcctInf } from "../accounts/stores";
|
|
|
|
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 [
|
|
() => {
|
|
try {
|
|
const value = accessor();
|
|
if (value) {
|
|
return value;
|
|
}
|
|
} catch (reason) {
|
|
console.error("useSignedInProfiles: update acct info failed", reason);
|
|
}
|
|
|
|
return sessions().map((x) => ({ ...x, inf: x.account.inf }));
|
|
},
|
|
tools,
|
|
] as const;
|
|
}
|