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:
Paul
2021-07-05 10:59:48 +01:00
parent 02bbf78dcd
commit 7067627027
25 changed files with 226 additions and 149 deletions

View File

@@ -1,7 +1,7 @@
import { store } from ".";
import localForage from "localforage";
import { Provider } from "react-redux";
import { Children } from "../types/Preact";
import { dispatch, State, store } from ".";
import { useEffect, useState } from "preact/hooks";
interface Props {
@@ -15,7 +15,7 @@ export default function State(props: Props) {
localForage.getItem("state")
.then(state => {
if (state !== null) {
store.dispatch({ type: "__INIT", state });
dispatch({ type: "__INIT", state: state as State });
}
setLoaded(true);

View File

@@ -8,16 +8,8 @@ import { connect, ConnectedComponent } from "react-redux";
export function connectState<T>(
component: (props: any) => h.JSX.Element | null,
mapKeys: (state: State, props: T) => any,
useDispatcher?: boolean,
memoize?: boolean
): ConnectedComponent<(props: any) => h.JSX.Element | null, T> {
let c = (
useDispatcher
? connect(mapKeys, (dispatcher) => {
return { dispatcher };
})
: connect(mapKeys)
)(component);
let c = connect(mapKeys)(component);
return memoize ? memo(c) : c;
}

View File

@@ -1,6 +1,6 @@
import { createStore } from "redux";
import rootReducer from "./reducers";
import localForage from "localforage";
import rootReducer, { Action } from "./reducers";
import { Core } from "revolt.js/dist/api/objects";
import { Typing } from "./reducers/typing";
@@ -77,3 +77,7 @@ store.subscribe(() => {
sectionToggle
});
});
export function dispatch(action: Action) {
store.dispatch(action);
}

View File

@@ -47,8 +47,6 @@ export type Action =
| SectionToggleAction
| { type: "__INIT"; state: State };
export type WithDispatcher = { dispatcher: (action: Action) => void };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function filter(obj: any, keys: string[]) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any