added settings

This commit is contained in:
thislight 2024-07-22 21:57:04 +08:00
parent 5ec00d4999
commit 5833e5a76b
15 changed files with 359 additions and 91 deletions

View file

@ -1,10 +1,35 @@
import { Accessor, createResource } from "solid-js";
import type { mastodon } from "masto";
import { useSessions } from "./clients";
import { updateAcctInf } from "../accounts/stores";
export function useAcctProfile(client: Accessor<mastodon.rest.Client>) {
return createResource(client, (client) => {
return client.v1.accounts.verifyCredentials()
}, {
name: "MastodonAccountProfile"
})
return createResource(
client,
(client) => {
return client.v1.accounts.verifyCredentials();
},
{
name: "MastodonAccountProfile",
},
);
}
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 [
() => {
if (accessor.loading) {
accessor();
return sessions().map((x) => ({ ...x, inf: x.account.inf }));
}
return accessor();
},
tools,
] as const;
}