import { createResource, createSignal, For, Show } from "solid-js";
import { api, type ShareInfo, type TokenInfo } from "./api";
import { ago, until } from "./live";
import { useSession } from "./session";
/**
* The only place individual phones are visible.
*
* Positions belong to the account, so a token is a credential and nothing else.
* Listing them with last-seen is what makes a forgotten phone in a drawer — the
* one that drags the live marker back and forth — visible and revocable.
*/
export default function Settings() {
const me = useSession().me;
const [tokens, { refetch }] = createResource(() => api.tokens());
const [message, setMessage] = createSignal(null);
const now = Math.floor(Date.now() / 1000);
async function revoke(t: TokenInfo) {
if (!confirm(`Revoke "${t.name}"? That phone has to log in again.`)) return;
await api.revokeToken(t.token_id);
void refetch();
}
async function revokeOthers() {
if (!confirm("Revoke every device token on this account?")) return;
const { revoked } = await api.revokeOthers();
setMessage(`${revoked} token(s) revoked`);
void refetch();
}
return (