fix: pull Client into state early

(should fix empty server list)
This commit is contained in:
Paul Makles 2022-06-09 14:40:54 +01:00
parent 67c8418c31
commit ee80dfd3c8
3 changed files with 5 additions and 4 deletions

View file

@ -8,7 +8,6 @@ import { useContext, useEffect, useMemo, useState } from "preact/hooks";
import { useApplicationState } from "../../mobx/State"; import { useApplicationState } from "../../mobx/State";
import Preloader from "../../components/ui/Preloader"; import Preloader from "../../components/ui/Preloader";
import { Children } from "../../types/Preact"; import { Children } from "../../types/Preact";
import { useIntermediate } from "../intermediate/Intermediate"; import { useIntermediate } from "../intermediate/Intermediate";
import { registerEvents } from "./events"; import { registerEvents } from "./events";
@ -80,6 +79,7 @@ export default observer(({ children }: Props) => {
}, [state.auth.getSession()]); }, [state.auth.getSession()]);
useEffect(() => registerEvents(state, setStatus, client), [client]); useEffect(() => registerEvents(state, setStatus, client), [client]);
useEffect(() => state.registerListeners(client), [client]);
if (!loaded || status === ClientStatus.LOADING) { if (!loaded || status === ClientStatus.LOADING) {
return <Preloader type="spinner" />; return <Preloader type="spinner" />;

View file

@ -22,9 +22,6 @@ export default function SyncManager() {
} }
}, [client]); }, [client]);
// Keep data synced.
useEffect(() => state.registerListeners(client), [client]);
// Take data updates from Revolt. // Take data updates from Revolt.
useEffect(() => { useEffect(() => {
if (!client) return; if (!client) return;

View file

@ -73,10 +73,14 @@ export default class Ordering implements Store, Persistent<Data>, Syncable {
} }
} }
console.info("out1", out);
for (const id of known) { for (const id of known) {
out.push(this.state.client!.servers.get(id)!); out.push(this.state.client!.servers.get(id)!);
} }
console.info("out2", out);
return out; return out;
} }