diff --git a/src/masto/acct.ts b/src/masto/acct.ts deleted file mode 100644 index ff9d488..0000000 --- a/src/masto/acct.ts +++ /dev/null @@ -1,28 +0,0 @@ -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; -} diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index 0bb04d7..dd82f25 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -31,12 +31,10 @@ import { import { A, useNavigate } from "@solidjs/router"; import { Title } from "../material/typography.jsx"; import { css } from "solid-styled"; -import { useSignedInProfiles } from "../masto/acct.js"; import { signOut, type Account } from "../accounts/stores.js"; import { format } from "date-fns"; import { useStore } from "@nanostores/solid"; import { $settings } from "./stores.js"; -import { useRegisterSW } from "virtual:pwa-register/solid"; import { autoMatchLangTag, autoMatchRegion, @@ -46,6 +44,7 @@ import { import { type Template } from "@solid-primitives/i18n"; import BottomSheet from "../material/BottomSheet.jsx"; import { useServiceWorker } from "../platform/host.js"; +import { useSessions } from "../masto/clients.js"; type Strings = { ["lang.auto"]: Template<{ detected: string }>; @@ -64,7 +63,7 @@ const Settings: ParentComponent = (props) => { const { needRefresh, offlineReady } = useServiceWorker(); const dateFnLocale = useDateFnLocale(); - const [profiles] = useSignedInProfiles(); + const profiles = useSessions(); const doSignOut = (acct: Account) => { signOut((a) => a.site === acct.site && a.accessToken === acct.accessToken); @@ -118,9 +117,9 @@ const Settings: ParentComponent = (props) => { - {({ account: acct, inf }) => ( -