diff --git a/src/context/intermediate/Intermediate.tsx b/src/context/intermediate/Intermediate.tsx
index 9be2fe29..f5d072d0 100644
--- a/src/context/intermediate/Intermediate.tsx
+++ b/src/context/intermediate/Intermediate.tsx
@@ -24,6 +24,7 @@ export type Screen =
| { id: "clipboard"; text: string }
| { id: "token_reveal"; token: string; username: string }
| { id: "external_link_prompt"; link: string }
+ | { id: "sessions", confirm: () => void }
| {
id: "_prompt";
question: Children;
diff --git a/src/context/intermediate/Modals.tsx b/src/context/intermediate/Modals.tsx
index f8b57109..60d0bce7 100644
--- a/src/context/intermediate/Modals.tsx
+++ b/src/context/intermediate/Modals.tsx
@@ -9,7 +9,8 @@ import { InputModal } from "./modals/Input";
import { OnboardingModal } from "./modals/Onboarding";
import { PromptModal } from "./modals/Prompt";
import { SignedOutModal } from "./modals/SignedOut";
-import {ExternalLinkModal} from "./modals/ExternalLinkPrompt";
+import { ExternalLinkModal} from "./modals/ExternalLinkPrompt";
+import { SessionsModal } from "./modals/SessionsPrompt";
import { TokenRevealModal } from "./modals/TokenReveal";
export interface Props {
@@ -40,6 +41,8 @@ export default function Modals({ screen, openScreen }: Props) {
return ;
case "external_link_prompt":
return ;
+ case "sessions":
+ return ;
}
return null;
diff --git a/src/context/intermediate/modals/SessionsPrompt.tsx b/src/context/intermediate/modals/SessionsPrompt.tsx
new file mode 100644
index 00000000..b7de71c6
--- /dev/null
+++ b/src/context/intermediate/modals/SessionsPrompt.tsx
@@ -0,0 +1,38 @@
+import { Text } from "preact-i18n";
+
+import Modal from "../../../components/ui/Modal";
+
+interface Props {
+ onClose: () => void;
+ confirm: () => void;
+}
+
+export function SessionsModal({ onClose, confirm}: Props) {
+ return (
+ }
+ actions={[
+ {
+ onClick: () => {
+ onClose()
+ },
+ confirmation: true,
+ contrast: true,
+ accent: true,
+ children:
+ },
+ {
+ onClick: () => {
+ confirm()
+ onClose()
+ },
+ confirmation: true,
+ children:
+ }
+ ]}>
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/settings/panes/Sessions.tsx b/src/pages/settings/panes/Sessions.tsx
index a4fe5f6b..f3c2134f 100644
--- a/src/pages/settings/panes/Sessions.tsx
+++ b/src/pages/settings/panes/Sessions.tsx
@@ -20,6 +20,7 @@ import { useContext, useEffect, useState } from "preact/hooks";
import { dayjs } from "../../../context/Locale";
import { AppContext } from "../../../context/revoltjs/RevoltClient";
+import { useIntermediate } from "../../../context/intermediate/Intermediate";
import Button from "../../../components/ui/Button";
import Preloader from "../../../components/ui/Preloader";
@@ -39,6 +40,8 @@ export function Sessions() {
const [attemptingDelete, setDelete] = useState([]);
const history = useHistory();
+ const { openScreen } = useIntermediate();
+
function switchPage(to: string) {
history.replace(`/settings/${to}`);
}
@@ -212,21 +215,26 @@ export function Sessions() {
{
- // ! FIXME: add to rAuth
- const del: string[] = [];
- render.forEach((session) => {
- if (deviceId !== session._id) {
- del.push(session._id);
+ openScreen({
+ id: "sessions",
+ confirm: async () => {
+ // ! FIXME: add to rAuth
+ const del: string[] = [];
+ render.forEach((session) => {
+ if (deviceId !== session._id) {
+ del.push(session._id);
+ }
+ });
+
+ setDelete(del);
+
+ for (const id of del) {
+ await client.api.delete(`/auth/session/${id as ""}`);
+ }
+
+ setSessions(sessions.filter((x) => x._id === deviceId));
}
- });
-
- setDelete(del);
-
- for (const id of del) {
- await client.api.delete(`/auth/session/${id as ""}`);
- }
-
- setSessions(sessions.filter((x) => x._id === deviceId));
+ })
}}
icon={}
action={"chevron"}
@@ -247,3 +255,4 @@ export function Sessions() {
);
}
+