mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
Refactor + add message box.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { ReactNode } from "react";
|
||||
import { useContext } from "preact/hooks";
|
||||
import { Redirect } from "react-router-dom";
|
||||
import { Children } from "../../types/Preact";
|
||||
|
||||
import { OperationsContext } from "./RevoltClient";
|
||||
|
||||
interface Props {
|
||||
auth?: boolean;
|
||||
children: ReactNode | ReactNode[];
|
||||
children: Children;
|
||||
}
|
||||
|
||||
export const CheckAuth = (props: Props) => {
|
||||
|
||||
@@ -11,8 +11,17 @@ export interface HookContext {
|
||||
export function useForceUpdate(context?: HookContext): HookContext {
|
||||
const client = useContext(AppContext);
|
||||
if (context) return context;
|
||||
const [, updateState] = useState({});
|
||||
return { client, forceUpdate: useCallback(() => updateState({}), []) };
|
||||
const H = useState(undefined);
|
||||
var updateState: (_: undefined) => void;
|
||||
if (Array.isArray(H)) {
|
||||
let [, u] = H;
|
||||
updateState = u;
|
||||
} else {
|
||||
console.warn('Failed to construct using useState.');
|
||||
console.warn(H);
|
||||
updateState = ()=>{};
|
||||
}
|
||||
return { client, forceUpdate: useCallback(() => updateState(undefined), []) };
|
||||
}
|
||||
|
||||
function useObject(type: string, id?: string | string[], context?: HookContext) {
|
||||
|
||||
Reference in New Issue
Block a user