2024-09-14 11:55:37 +00:00
|
|
|
import { For, Show, type ParentComponent } from "solid-js";
|
2024-07-22 13:57:04 +00:00
|
|
|
import Scaffold from "../material/Scaffold.js";
|
|
|
|
import {
|
|
|
|
AppBar,
|
|
|
|
Divider,
|
|
|
|
IconButton,
|
|
|
|
List,
|
|
|
|
ListItem,
|
|
|
|
ListItemButton,
|
|
|
|
ListItemSecondaryAction,
|
|
|
|
ListItemText,
|
|
|
|
ListSubheader,
|
|
|
|
Switch,
|
|
|
|
Toolbar,
|
|
|
|
} from "@suid/material";
|
2024-09-14 11:55:37 +00:00
|
|
|
import {
|
|
|
|
Close as CloseIcon,
|
|
|
|
Refresh as RefreshIcon,
|
|
|
|
} from "@suid/icons-material";
|
2024-07-22 13:57:04 +00:00
|
|
|
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 { intlFormat } from "date-fns";
|
2024-07-23 00:28:47 +00:00
|
|
|
import { useStore } from "@nanostores/solid";
|
|
|
|
import { $settings } from "./stores.js";
|
2024-09-14 11:55:37 +00:00
|
|
|
import { useRegisterSW } from "virtual:pwa-register/solid";
|
2024-07-22 13:57:04 +00:00
|
|
|
|
|
|
|
const Settings: ParentComponent = () => {
|
|
|
|
const navigate = useNavigate();
|
2024-07-23 00:28:47 +00:00
|
|
|
const settings$ = useStore($settings);
|
2024-09-14 11:55:37 +00:00
|
|
|
const {
|
|
|
|
needRefresh: [needRefresh],
|
|
|
|
} = useRegisterSW();
|
2024-07-22 13:57:04 +00:00
|
|
|
|
|
|
|
const [profiles] = useSignedInProfiles();
|
|
|
|
|
|
|
|
const doSignOut = (acct: Account) => {
|
|
|
|
signOut((a) => a.site === acct.site && a.accessToken === acct.accessToken);
|
|
|
|
};
|
|
|
|
|
|
|
|
css`
|
|
|
|
ul {
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.setting-list {
|
2024-07-24 06:27:20 +00:00
|
|
|
padding-bottom: calc(var(--safe-area-inset-bottom, 0px) + 16px);
|
2024-07-22 13:57:04 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
return (
|
|
|
|
<Scaffold
|
|
|
|
topbar={
|
|
|
|
<AppBar position="static">
|
2024-09-14 11:55:37 +00:00
|
|
|
<Toolbar
|
|
|
|
variant="dense"
|
|
|
|
sx={{ paddingTop: "var(--safe-area-inset-top, 0px)" }}
|
|
|
|
>
|
2024-08-13 07:08:29 +00:00
|
|
|
<IconButton color="inherit" onClick={[navigate, -1]} disableRipple>
|
2024-07-22 13:57:04 +00:00
|
|
|
<CloseIcon />
|
|
|
|
</IconButton>
|
|
|
|
<Title>Settings</Title>
|
|
|
|
</Toolbar>
|
|
|
|
</AppBar>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<List class="setting-list" use:solid-styled>
|
|
|
|
<li>
|
|
|
|
<ul>
|
|
|
|
<ListSubheader>Accounts</ListSubheader>
|
|
|
|
<ListItem>
|
|
|
|
<ListItemText>All Notifications</ListItemText>
|
|
|
|
<ListItemSecondaryAction>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Switch value={false} />
|
2024-07-22 13:57:04 +00:00
|
|
|
</ListItemSecondaryAction>
|
|
|
|
</ListItem>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Divider />
|
2024-07-22 13:57:04 +00:00
|
|
|
<ListItem>
|
|
|
|
<ListItemText>Sign in...</ListItemText>
|
|
|
|
</ListItem>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Divider />
|
2024-07-22 13:57:04 +00:00
|
|
|
</ul>
|
|
|
|
<For each={profiles()}>
|
|
|
|
{({ account: acct, inf }) => (
|
|
|
|
<ul data-site={acct.site} data-username={inf?.username}>
|
|
|
|
<ListSubheader>{`@${inf?.username ?? "..."}@${new URL(acct.site).host}`}</ListSubheader>
|
|
|
|
<ListItem>
|
|
|
|
<ListItemText>Notifications</ListItemText>
|
|
|
|
<ListItemSecondaryAction>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Switch value={false} />
|
2024-07-22 13:57:04 +00:00
|
|
|
</ListItemSecondaryAction>
|
|
|
|
</ListItem>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Divider />
|
2024-07-22 13:57:04 +00:00
|
|
|
<ListItemButton onClick={[doSignOut, acct]}>
|
|
|
|
<ListItemText>Sign out</ListItemText>
|
|
|
|
</ListItemButton>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Divider />
|
2024-07-22 13:57:04 +00:00
|
|
|
</ul>
|
|
|
|
)}
|
|
|
|
</For>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<ListSubheader>Reading</ListSubheader>
|
|
|
|
<ListItem>
|
|
|
|
<ListItemText secondary="Regular">Fonts</ListItemText>
|
|
|
|
</ListItem>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Divider />
|
|
|
|
<ListItem
|
|
|
|
onClick={(e) =>
|
|
|
|
$settings.setKey(
|
|
|
|
"prefetchTootsDisabled",
|
|
|
|
!settings$().prefetchTootsDisabled,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
>
|
2024-07-22 13:57:04 +00:00
|
|
|
<ListItemText secondary="Tutu will download toots before you scroll to the position.">
|
|
|
|
Prefetch Toots
|
|
|
|
</ListItemText>
|
|
|
|
<ListItemSecondaryAction>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Switch checked={!settings$().prefetchTootsDisabled} />
|
2024-07-22 13:57:04 +00:00
|
|
|
</ListItemSecondaryAction>
|
|
|
|
</ListItem>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Divider />
|
2024-07-22 13:57:04 +00:00
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<ListSubheader>This Application</ListSubheader>
|
|
|
|
<ListItem>
|
|
|
|
<ListItemText secondary="Comformtable tooting experience.">
|
|
|
|
About Tutu
|
|
|
|
</ListItemText>
|
|
|
|
</ListItem>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Divider />
|
2024-07-22 13:57:04 +00:00
|
|
|
<ListItem>
|
|
|
|
<ListItemText
|
|
|
|
secondary={`Using v${import.meta.env.PACKAGE_VERSION} (built on ${intlFormat(import.meta.env.BUILT_AT)}, ${import.meta.env.MODE})`}
|
|
|
|
>
|
2024-09-14 11:55:37 +00:00
|
|
|
{needRefresh()
|
|
|
|
? "An update is ready, restart the Tutu to apply"
|
|
|
|
: "No updates"}
|
2024-07-22 13:57:04 +00:00
|
|
|
</ListItemText>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Show when={needRefresh()}>
|
|
|
|
<ListItemSecondaryAction>
|
|
|
|
<IconButton aria-label="Restart Now" onClick={() => window.location.reload()}>
|
|
|
|
<RefreshIcon />
|
|
|
|
</IconButton>
|
|
|
|
</ListItemSecondaryAction>
|
|
|
|
</Show>
|
2024-07-22 13:57:04 +00:00
|
|
|
</ListItem>
|
2024-09-14 11:55:37 +00:00
|
|
|
<Divider />
|
2024-07-22 13:57:04 +00:00
|
|
|
</li>
|
|
|
|
</List>
|
|
|
|
</Scaffold>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Settings;
|