feat: add disable / delete funct; bump revolt-api

This commit is contained in:
Paul Makles
2022-06-10 14:32:21 +01:00
parent e0ca1681bd
commit 6be0807433
8 changed files with 47 additions and 26 deletions

View File

@@ -177,7 +177,7 @@ export function SpecialInputModal(props: SpecialProps) {
question={"Add Friend"}
callback={(username) =>
client.api
.put(`/users/${username as ""}/friend`)
.post(`/users/friend`, { username })
.then(undefined)
}
/>

View File

@@ -3,7 +3,7 @@ import { observer } from "mobx-react-lite";
import { Client } from "revolt.js";
import { createContext } from "preact";
import { useContext, useEffect, useState } from "preact/hooks";
import { useCallback, useContext, useEffect, useState } from "preact/hooks";
import { Preloader } from "@revoltchat/ui";
@@ -29,7 +29,7 @@ export interface ClientOperations {
export const AppContext = createContext<Client>(null!);
export const StatusContext = createContext<ClientStatus>(null!);
export const LogOutContext = createContext(() => {});
export const LogOutContext = createContext((avoidReq?: boolean) => {});
type Props = {
children: Children;
@@ -42,10 +42,10 @@ export default observer(({ children }: Props) => {
const [status, setStatus] = useState(ClientStatus.LOADING);
const [loaded, setLoaded] = useState(false);
function logout() {
const logout = useCallback((avoidReq?: boolean) => {
setLoaded(false);
client.logout(false);
}
client.logout(avoidReq);
}, []);
useEffect(() => {
if (navigator.onLine) {