mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
feat(modal): port Error and ShowToken
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -25,6 +25,7 @@ import { useTranslation } from "../../../lib/i18n";
|
||||
import { stopPropagation } from "../../../lib/stopPropagation";
|
||||
|
||||
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
||||
import { modalController } from "../../../context/modals";
|
||||
import { FileUploader } from "../../../context/revoltjs/FileUploads";
|
||||
import { useClient } from "../../../context/revoltjs/RevoltClient";
|
||||
|
||||
@@ -366,10 +367,10 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||
onClick={(ev) =>
|
||||
stopPropagation(
|
||||
ev,
|
||||
openScreen({
|
||||
id: "token_reveal",
|
||||
modalController.push({
|
||||
type: "show_token",
|
||||
token: bot.token,
|
||||
username: user!.username,
|
||||
name: user!.username,
|
||||
}),
|
||||
)
|
||||
}>
|
||||
|
||||
@@ -10,12 +10,11 @@ import { urlBase64ToUint8Array } from "../../../lib/conversion";
|
||||
|
||||
import { useApplicationState } from "../../../mobx/State";
|
||||
|
||||
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
||||
import { modalController } from "../../../context/modals";
|
||||
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
||||
|
||||
export const Notifications = observer(() => {
|
||||
const client = useContext(AppContext);
|
||||
const { openScreen } = useIntermediate();
|
||||
const settings = useApplicationState().settings;
|
||||
const [pushEnabled, setPushEnabled] = useState<undefined | boolean>(
|
||||
undefined,
|
||||
@@ -52,8 +51,8 @@ export const Notifications = observer(() => {
|
||||
await Notification.requestPermission();
|
||||
|
||||
if (permission !== "granted") {
|
||||
return openScreen({
|
||||
id: "error",
|
||||
return modalController.push({
|
||||
type: "error",
|
||||
error: "DeniedNotification",
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user