mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 17:35:28 +00:00
Fix: Add default for font combo box.
Don't pass dispatcher in, just provide it globally. Fix: Allow clicking through to profile from server sidebar.
This commit is contained in:
@@ -2,12 +2,12 @@ import { openDB } from 'idb';
|
||||
import { Client } from "revolt.js";
|
||||
import { takeError } from "./util";
|
||||
import { createContext } from "preact";
|
||||
import { dispatch } from '../../redux';
|
||||
import { Children } from "../../types/Preact";
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { Route } from "revolt.js/dist/api/routes";
|
||||
import { connectState } from "../../redux/connector";
|
||||
import Preloader from "../../components/ui/Preloader";
|
||||
import { WithDispatcher } from "../../redux/reducers";
|
||||
import { AuthState } from "../../redux/reducers/auth";
|
||||
import { useEffect, useMemo, useState } from "preact/hooks";
|
||||
import { useIntermediate } from '../intermediate/Intermediate';
|
||||
@@ -38,12 +38,12 @@ export const AppContext = createContext<Client>(undefined as any);
|
||||
export const StatusContext = createContext<ClientStatus>(undefined as any);
|
||||
export const OperationsContext = createContext<ClientOperations>(undefined as any);
|
||||
|
||||
type Props = WithDispatcher & {
|
||||
type Props = {
|
||||
auth: AuthState;
|
||||
children: Children;
|
||||
};
|
||||
|
||||
function Context({ auth, children, dispatcher }: Props) {
|
||||
function Context({ auth, children }: Props) {
|
||||
const history = useHistory();
|
||||
const { openScreen } = useIntermediate();
|
||||
const [status, setStatus] = useState(ClientStatus.INIT);
|
||||
@@ -91,7 +91,7 @@ function Context({ auth, children, dispatcher }: Props) {
|
||||
const onboarding = await client.login(data);
|
||||
setReconnectDisallowed(false);
|
||||
const login = () =>
|
||||
dispatcher({
|
||||
dispatch({
|
||||
type: "LOGIN",
|
||||
session: client.session as any
|
||||
});
|
||||
@@ -113,10 +113,10 @@ function Context({ auth, children, dispatcher }: Props) {
|
||||
}
|
||||
},
|
||||
logout: async shouldRequest => {
|
||||
dispatcher({ type: "LOGOUT" });
|
||||
dispatch({ type: "LOGOUT" });
|
||||
|
||||
client.reset();
|
||||
dispatcher({ type: "RESET" });
|
||||
dispatch({ type: "RESET" });
|
||||
|
||||
openScreen({ id: "none" });
|
||||
setStatus(ClientStatus.READY);
|
||||
@@ -144,7 +144,7 @@ function Context({ auth, children, dispatcher }: Props) {
|
||||
}
|
||||
}, [ client, auth.active ]);
|
||||
|
||||
useEffect(() => registerEvents({ operations, dispatcher }, setStatus, client), [ client ]);
|
||||
useEffect(() => registerEvents({ operations }, setStatus, client), [ client ]);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
@@ -153,7 +153,7 @@ function Context({ auth, children, dispatcher }: Props) {
|
||||
}
|
||||
|
||||
if (auth.active) {
|
||||
dispatcher({ type: "QUEUE_FAIL_ALL" });
|
||||
dispatch({ type: "QUEUE_FAIL_ALL" });
|
||||
|
||||
const active = auth.accounts[auth.active];
|
||||
client.user = client.users.get(active.session.user_id);
|
||||
@@ -225,6 +225,5 @@ export default connectState<{ children: Children }>(
|
||||
auth: state.auth,
|
||||
sync: state.sync
|
||||
};
|
||||
},
|
||||
true
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user