feat: implement useClient from client controller

This commit is contained in:
Paul Makles
2022-06-28 19:59:58 +01:00
parent ce88fab714
commit 5f2311b09c
72 changed files with 330 additions and 457 deletions

View File

@@ -4,14 +4,12 @@ import { observer } from "mobx-react-lite";
import { useParams } from "react-router-dom";
import { Channel, Server, User, API } from "revolt.js";
import { useContext, useEffect, useState } from "preact/hooks";
import { useEffect, useState } from "preact/hooks";
import {
ClientStatus,
StatusContext,
useSession,
useClient,
} from "../../../context/revoltjs/RevoltClient";
} from "../../../controllers/client/ClientController";
import { GenericSidebarBase } from "../SidebarBase";
import MemberList, { MemberListGroup } from "./MemberList";
@@ -205,18 +203,18 @@ function shouldSkipOffline(id: string) {
export const ServerMemberSidebar = observer(
({ channel }: { channel: Channel }) => {
const client = useClient();
const status = useContext(StatusContext);
const session = useSession()!;
const client = session.client!;
useEffect(() => {
const server_id = channel.server_id!;
if (status === ClientStatus.ONLINE && !FETCHED.has(server_id)) {
if (session.state === "Online" && !FETCHED.has(server_id)) {
FETCHED.add(server_id);
channel
.server!.syncMembers(shouldSkipOffline(server_id))
.catch(() => FETCHED.delete(server_id));
}
}, [status, channel]);
}, [session.state, channel]);
const entries = useEntries(
channel,