feat: finish reimplementation of server list

This commit is contained in:
Paul Makles
2022-05-27 19:57:41 +01:00
parent 94dd4b464a
commit 588cb7c019
7 changed files with 366 additions and 185 deletions

View File

@@ -1,25 +1,40 @@
import { observer } from "mobx-react-lite";
import { Link, useParams } from "react-router-dom";
import { useParams } from "react-router-dom";
import { useCallback } from "preact/hooks";
import { ServerList } from "@revoltchat/ui";
import { useApplicationState } from "../../../mobx/State";
import { useIntermediate } from "../../../context/intermediate/Intermediate";
import { useClient } from "../../../context/revoltjs/RevoltClient";
/**
* Server list sidebar shim component
*/
export default observer(() => {
const client = useClient();
const state = useApplicationState();
const { openScreen } = useIntermediate();
const { server: server_id } = useParams<{ server?: string }>();
const servers = [...client.servers.values()];
const createServer = useCallback(
() =>
openScreen({
id: "special_input",
type: "create_server",
}),
[],
);
return (
<ServerList
active={server_id!}
servers={servers as any}
linkComponent={({ id, children }) => (
<Link to={`/server/${id}`}>
<a>{children}</a>
</Link>
)}
client={client}
active={server_id}
createServer={createServer}
permit={state.notifications}
home={state.layout.getLastHomePath}
/>
);
});