Load member sidebar into MobX state.

This commit is contained in:
Paul
2021-07-29 21:01:03 +01:00
parent b06729d0b3
commit b0681dfc99
8 changed files with 57 additions and 31 deletions

View File

@@ -8,13 +8,13 @@ import { useContext, useEffect, useMemo, useState } from "preact/hooks";
import { SingletonMessageRenderer } from "../../lib/renderer/Singleton";
import { useData } from "../../mobx/State";
import { dispatch } from "../../redux";
import { connectState } from "../../redux/connector";
import { AuthState } from "../../redux/reducers/auth";
import Preloader from "../../components/ui/Preloader";
import { useData } from "../../mobx/State";
import { Children } from "../../types/Preact";
import { useIntermediate } from "../intermediate/Intermediate";
import { registerEvents, setReconnectDisallowed } from "./events";
@@ -158,10 +158,9 @@ function Context({ auth, children }: Props) {
};
}, [client, auth.active]);
const store = useData();
useEffect(
() => registerEvents({ operations }, setStatus, client, store),
[client, store],
() => registerEvents({ operations }, setStatus, client),
[client],
);
useEffect(() => {

View File

@@ -3,10 +3,10 @@ import { ClientboundNotification } from "revolt.js/dist/websocket/notifications"
import { StateUpdater } from "preact/hooks";
import { dispatch } from "../../redux";
import { DataStore } from "../../mobx";
import { useData } from "../../mobx/State";
import { dispatch } from "../../redux";
import { ClientOperations, ClientStatus } from "./RevoltClient";
export var preventReconnect = false;
@@ -20,7 +20,6 @@ export function registerEvents(
{ operations }: { operations: ClientOperations },
setStatus: StateUpdater<ClientStatus>,
client: Client,
store: DataStore,
) {
function attemptReconnect() {
if (preventReconnect) return;
@@ -48,7 +47,6 @@ export function registerEvents(
},
packet: (packet: ClientboundNotification) => {
store.packet(packet);
switch (packet.type) {
case "ChannelStartTyping": {
if (packet.user === client.user?._id) return;