import { BiLogosAndroid, BiLogosApple, BiLogosWindows, BiRegularQuestionMark, } from "solid-icons/bi"; import { FaBrandsLinux } from "solid-icons/fa"; import { Accessor, For, Match, Show, Switch, createMemo, onMount, } from "solid-js"; import { Trans } from "@lingui-solid/solid/macro"; import { Session } from "stoat.js"; import { styled } from "styled-system/jsx"; import { useClient } from "@revolt/client"; import { useModals } from "@revolt/modal"; import { CategoryButton, CategoryButtonGroup, CategoryCollapse, CircularProgress, Column, Time, iconSize, } from "@revolt/ui"; import MdLogout from "@material-design-icons/svg/outlined/logout.svg?component-solid"; /** * Sessions */ export function Sessions() { const client = useClient(); onMount(() => client().sessions.fetch()); /** * Sort the other sessions by created date */ const otherSessions = createMemo(() => client() .sessions.filter((session) => !session.current) .sort((a, b) => +b.createdAt - +a.createdAt), ); return ( }> ); } /** * Manage user's current session */ function ManageCurrentSession(props: { otherSessions: Accessor }) { const client = useClient(); const { openModal } = useModals(); /** * Resolve current session */ const currentSession = () => client().sessions.get(client().sessionId!); return ( Current Session} description={currentSession()?.name} icon={} > currentSession() && openModal({ type: "rename_session", session: currentSession()!, }) } > Rename {/* } description={Keeps your last sessions active and automatically logs you out of other ones"} > Keep Last Active Sessions */} openModal({ type: "sign_out_sessions", client: client(), }) } icon={} description={ Logs you out of all sessions except this device. } > Log Out Other Sessions ); } /** * List other logged in sessions */ function ListOtherSessions(props: { otherSessions: Accessor }) { const { openModal } = useModals(); return ( {(session) => ( } title={{session.name}} description={ Created } > openModal({ type: "rename_session", session, }) } > Rename session.delete()} > Log Out )} ); } /** * Capitalize session titles */ const Capitalise = styled("div", { base: { textTransform: "capitalize", }, }); /** * Show icon for session */ function SessionIcon(props: { session?: Session }) { return ( }> ); }