feat(modal): port Error and ShowToken

This commit is contained in:
Paul Makles
2022-06-18 12:25:56 +01:00
parent 374be319c4
commit d10bd96900
13 changed files with 92 additions and 61 deletions

View File

@@ -6,7 +6,7 @@ import { useContext, useEffect } from "preact/hooks";
import { Header } from "@revoltchat/ui";
import { useIntermediate } from "../context/intermediate/Intermediate";
import { modalController } from "../context/modals";
import {
AppContext,
ClientStatus,
@@ -18,7 +18,6 @@ export default function Open() {
const client = useContext(AppContext);
const status = useContext(StatusContext);
const { id } = useParams<{ id: string }>();
const { openScreen } = useIntermediate();
if (status !== ClientStatus.ONLINE) {
return (
@@ -40,7 +39,12 @@ export default function Open() {
client
.user!.openDM()
.then((channel) => history.push(`/channel/${channel?._id}`))
.catch((error) => openScreen({ id: "error", error }));
.catch((error) =>
modalController.push({
type: "error",
error,
}),
);
return;
}
@@ -62,7 +66,12 @@ export default function Open() {
.get(id)
?.openDM()
.then((channel) => history.push(`/channel/${channel?._id}`))
.catch((error) => openScreen({ id: "error", error }));
.catch((error) =>
modalController.push({
type: "error",
error,
}),
);
}
return;