Merge branch 'master' into chore/component-migration

This commit is contained in:
Paul Makles
2022-06-09 14:48:45 +01:00
committed by GitHub
5 changed files with 27 additions and 29 deletions

View File

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

View File

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

View File

@@ -7,12 +7,12 @@ import { Children } from "../../types/Preact";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function takeError(error: any): string {
if (error.response) {
const status = error.response.status;
if (error.response.type) {
return error.response.type;
const type = error.response.data?.type;
if (type) {
return type;
}
switch (status) {
switch (error.response.status) {
case 429:
return "TooManyRequests";
case 401: