mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 17:11:55 +00:00
feat: add global error handling and reporting
This commit is contained in:
@@ -2,6 +2,8 @@ import { Route, Switch } from "react-router-dom";
|
||||
|
||||
import { lazy, Suspense } from "preact/compat";
|
||||
|
||||
import ErrorBoundary from "../lib/ErrorBoundary";
|
||||
|
||||
import Context from "../context";
|
||||
import { CheckAuth } from "../context/revoltjs/CheckAuth";
|
||||
|
||||
@@ -15,33 +17,35 @@ const RevoltApp = lazy(() => import("./RevoltApp"));
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
<Context>
|
||||
<Masks />
|
||||
{/*
|
||||
// @ts-expect-error typings mis-match between preact... and preact? */}
|
||||
<Suspense fallback={<Preloader type="spinner" />}>
|
||||
<Switch>
|
||||
<Route path="/login/verify/:token">
|
||||
<Login />
|
||||
</Route>
|
||||
<Route path="/login/reset/:token">
|
||||
<Login />
|
||||
</Route>
|
||||
<Route path="/invite/:code">
|
||||
<Invite />
|
||||
</Route>
|
||||
<Route path="/login">
|
||||
<CheckAuth>
|
||||
<ErrorBoundary>
|
||||
<Context>
|
||||
<Masks />
|
||||
{/*
|
||||
// @ts-expect-error typings mis-match between preact... and preact? */}
|
||||
<Suspense fallback={<Preloader type="spinner" />}>
|
||||
<Switch>
|
||||
<Route path="/login/verify/:token">
|
||||
<Login />
|
||||
</CheckAuth>
|
||||
</Route>
|
||||
<Route path="/">
|
||||
<CheckAuth auth>
|
||||
<RevoltApp />
|
||||
</CheckAuth>
|
||||
</Route>
|
||||
</Switch>
|
||||
</Suspense>
|
||||
</Context>
|
||||
</Route>
|
||||
<Route path="/login/reset/:token">
|
||||
<Login />
|
||||
</Route>
|
||||
<Route path="/invite/:code">
|
||||
<Invite />
|
||||
</Route>
|
||||
<Route path="/login">
|
||||
<CheckAuth>
|
||||
<Login />
|
||||
</CheckAuth>
|
||||
</Route>
|
||||
<Route path="/">
|
||||
<CheckAuth auth>
|
||||
<RevoltApp />
|
||||
</CheckAuth>
|
||||
</Route>
|
||||
</Switch>
|
||||
</Suspense>
|
||||
</Context>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export default function Developer() {
|
||||
const client = useContext(AppContext);
|
||||
const userPermission = client.user!.permission;
|
||||
const [ping, setPing] = useState<undefined | number>(client.websocket.ping);
|
||||
const [crash, setCrash] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(
|
||||
@@ -44,6 +45,8 @@ export default function Developer() {
|
||||
/>
|
||||
</div>
|
||||
<div style={{ padding: "16px" }}>
|
||||
<a onClick={() => setCrash(true)}>click to crash app</a>
|
||||
{crash && (window as any).sus.sus()}
|
||||
{/*<span>
|
||||
<b>Voice Status:</b> {VoiceStatus[voice.status]}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user