import { For, Show, type ParentComponent } from "solid-js"; import Scaffold from "../material/Scaffold.js"; import { AppBar, Divider, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemSecondaryAction, ListItemText, ListSubheader, NativeSelect, Switch, Toolbar, } from "@suid/material"; import { Close as CloseIcon, Logout, Public as PublicIcon, Refresh as RefreshIcon, Translate as TranslateIcon, } from "@suid/icons-material"; import { 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, intlFormat } from "date-fns"; import { useStore } from "@nanostores/solid"; import { $settings } from "./stores.js"; import { useRegisterSW } from "virtual:pwa-register/solid"; import { autoMatchLangTag, autoMatchRegion, createStringResource, SUPPORTED_LANGS, SUPPORTED_REGIONS, useDateFnLocale, } from "../platform/i18n.jsx"; import { resolveTemplate, translator, type Template } from "@solid-primitives/i18n"; type Strings = { ["lang.auto"]: Template<{detected: string}> } & Record const Settings: ParentComponent = () => { const [strings] = createStringResource( (code) => import(`./i18n/${code}.json`) as Promise<{ default: Strings; }>, () => import(`./i18n/lang-names.json`) ); const t = translator(strings, resolveTemplate); const navigate = useNavigate(); const settings$ = useStore($settings); const { needRefresh: [needRefresh], } = useRegisterSW(); const dateFnLocale = useDateFnLocale(); const [profiles] = useSignedInProfiles(); const doSignOut = (acct: Account) => { signOut((a) => a.site === acct.site && a.accessToken === acct.accessToken); }; css` ul { padding: 0; } .setting-list { padding-bottom: calc(var(--safe-area-inset-bottom, 0px) + 16px); } `; return ( {t("Settings")} } >
    • {t("Accounts")} {t("All Notifications")} {t("Sign in...")}
    {({ account: acct, inf }) => (
      {`@${inf?.username ?? "..."}@${new URL(acct.site).host}`} {t("Notifications")} {t("Sign out")}
    )}
  • {t("Reading")} $settings.setKey( "prefetchTootsDisabled", !settings$().prefetchTootsDisabled, ) } > {t("Prefetch Toots")}
  • {t("This Application")} {t("Language")} { $settings.setKey( "language", e.currentTarget.value === "xauto" ? undefined : e.currentTarget.value, ); }} > {(code) => } {t("Region")} { $settings.setKey( "region", e.currentTarget.value === "xauto" ? undefined : e.currentTarget.value, ); }} > {(code) => ( )} {t("About Tutu")} {needRefresh() ? t("updates.ready") : t("updates.no")} window.location.reload()} >
  • ); }; export default Settings;