forked from revoltchat/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContent.tsx
52 lines (47 loc) · 1.48 KB
/
Content.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Component, onMount } from "solid-js";
import { modalController } from "@revolt/modal";
import { Navigate, Route, Routes } from "@revolt/routing";
import { state } from "@revolt/state";
import { DevelopmentPage } from "./Development";
import { Friends } from "./Friends";
import { HomePage } from "./Home";
import { ServerHome } from "./ServerHome";
import { ChannelPage } from "./channels/ChannelPage";
/**
* Redirect PWA start to the last active path
*/
function PWARedirect() {
return <Navigate href={state.layout.getLastActivePath()} />;
}
/**
* Open settings and redirect to last active path
*/
function SettingsRedirect() {
onMount(() => modalController.push({ type: "settings" }));
return <PWARedirect />;
}
/**
* Render content without sidebars
*/
export const Content: Component = () => {
return (
<Routes>
<Route
path="/server/:server/*"
element={
<Routes>
<Route path="/channel/:channel/*" component={ChannelPage} />
<Route path="/*" component={ServerHome} />
</Routes>
}
/>
<Route path="/channel/:channel/*" component={ChannelPage} />
<Route path="/dev" component={DevelopmentPage} />
<Route path="/friends" component={Friends} />
<Route path="/app" component={HomePage} />
<Route path="/pwa" component={PWARedirect} />
<Route path="/settings" component={SettingsRedirect} />
<Route path="/" element={<Navigate href="/app" />} />
</Routes>
);
};