mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15: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:
@@ -187,6 +187,9 @@ export const MONOSCAPE_FONTS: Record<MonoscapeFonts, { name: string, load: () =>
|
||||
export const FONT_KEYS = Object.keys(FONTS).sort();
|
||||
export const MONOSCAPE_FONT_KEYS = Object.keys(MONOSCAPE_FONTS).sort();
|
||||
|
||||
export const DEFAULT_FONT = 'Open Sans';
|
||||
export const DEFAULT_MONO_FONT = 'Fira Code';
|
||||
|
||||
// Generated from https://gitlab.insrt.uk/revolt/community/themes
|
||||
export const PRESETS: { [key: string]: Theme } = {
|
||||
light: {
|
||||
@@ -272,13 +275,13 @@ function Theme({ children, options }: Props) {
|
||||
|
||||
const root = document.documentElement.style;
|
||||
useEffect(() => {
|
||||
const font = theme.font ?? 'Inter';
|
||||
const font = theme.font ?? DEFAULT_FONT;
|
||||
root.setProperty('--font', `"${font}"`);
|
||||
FONTS[font].load();
|
||||
}, [ theme.font ]);
|
||||
|
||||
useEffect(() => {
|
||||
const font = theme.monoscapeFont ?? 'Fira Code';
|
||||
const font = theme.monoscapeFont ?? DEFAULT_MONO_FONT;
|
||||
root.setProperty('--monoscape-font', `"${font}"`);
|
||||
MONOSCAPE_FONTS[font].load();
|
||||
}, [ theme.monoscapeFont ]);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
);
|
||||
|
||||
@@ -7,10 +7,10 @@ import { AppContext } from "./RevoltClient";
|
||||
import { Typing } from "../../redux/reducers/typing";
|
||||
import { useContext, useEffect } from "preact/hooks";
|
||||
import { connectState } from "../../redux/connector";
|
||||
import { WithDispatcher } from "../../redux/reducers";
|
||||
import { QueuedMessage } from "../../redux/reducers/queue";
|
||||
import { dispatch } from "../../redux";
|
||||
|
||||
type Props = WithDispatcher & {
|
||||
type Props = {
|
||||
messages: QueuedMessage[];
|
||||
typing: Typing
|
||||
};
|
||||
@@ -19,7 +19,7 @@ function StateMonitor(props: Props) {
|
||||
const client = useContext(AppContext);
|
||||
|
||||
useEffect(() => {
|
||||
props.dispatcher({
|
||||
dispatch({
|
||||
type: 'QUEUE_DROP_ALL'
|
||||
});
|
||||
}, [ ]);
|
||||
@@ -29,7 +29,7 @@ function StateMonitor(props: Props) {
|
||||
if (!msg.nonce) return;
|
||||
if (!props.messages.find(x => x.id === msg.nonce)) return;
|
||||
|
||||
props.dispatcher({
|
||||
dispatch({
|
||||
type: 'QUEUE_REMOVE',
|
||||
nonce: msg.nonce
|
||||
});
|
||||
@@ -47,7 +47,7 @@ function StateMonitor(props: Props) {
|
||||
|
||||
for (let user of users) {
|
||||
if (+ new Date() > user.started + 5000) {
|
||||
props.dispatcher({
|
||||
dispatch({
|
||||
type: 'TYPING_STOP',
|
||||
channel,
|
||||
user: user.id
|
||||
@@ -73,6 +73,5 @@ export default connectState(
|
||||
messages: [...state.queue],
|
||||
typing: state.typing
|
||||
};
|
||||
},
|
||||
true
|
||||
}
|
||||
);
|
||||
|
||||
@@ -7,14 +7,14 @@ import { Language } from "../Locale";
|
||||
import { Sync } from "revolt.js/dist/api/objects";
|
||||
import { useContext, useEffect } from "preact/hooks";
|
||||
import { connectState } from "../../redux/connector";
|
||||
import { WithDispatcher } from "../../redux/reducers";
|
||||
import { Settings } from "../../redux/reducers/settings";
|
||||
import { Notifications } from "../../redux/reducers/notifications";
|
||||
import { AppContext, ClientStatus, StatusContext } from "./RevoltClient";
|
||||
import { ClientboundNotification } from "revolt.js/dist/websocket/notifications";
|
||||
import { DEFAULT_ENABLED_SYNC, SyncData, SyncKeys, SyncOptions } from "../../redux/reducers/sync";
|
||||
import { dispatch } from "../../redux";
|
||||
|
||||
type Props = WithDispatcher & {
|
||||
type Props = {
|
||||
settings: Settings,
|
||||
locale: Language,
|
||||
sync: SyncOptions,
|
||||
@@ -54,7 +54,7 @@ function SyncManager(props: Props) {
|
||||
client
|
||||
.syncFetchSettings(DEFAULT_ENABLED_SYNC.filter(x => !props.sync?.disabled?.includes(x)))
|
||||
.then(data => {
|
||||
props.dispatcher({
|
||||
dispatch({
|
||||
type: 'SYNC_UPDATE',
|
||||
update: mapSync(data)
|
||||
});
|
||||
@@ -62,13 +62,13 @@ function SyncManager(props: Props) {
|
||||
|
||||
client
|
||||
.syncFetchUnreads()
|
||||
.then(unreads => props.dispatcher({ type: 'UNREADS_SET', unreads }));
|
||||
.then(unreads => dispatch({ type: 'UNREADS_SET', unreads }));
|
||||
}
|
||||
}, [ status ]);
|
||||
|
||||
function syncChange(key: SyncKeys, data: any) {
|
||||
let timestamp = + new Date();
|
||||
props.dispatcher({
|
||||
dispatch({
|
||||
type: 'SYNC_SET_REVISION',
|
||||
key,
|
||||
timestamp
|
||||
@@ -99,7 +99,7 @@ function SyncManager(props: Props) {
|
||||
if (packet.type === 'UserSettingsUpdate') {
|
||||
let update: { [key in SyncKeys]?: [ number, SyncData[key] ] } = mapSync(packet.update, props.sync.revision);
|
||||
|
||||
props.dispatcher({
|
||||
dispatch({
|
||||
type: 'SYNC_UPDATE',
|
||||
update
|
||||
});
|
||||
@@ -122,6 +122,5 @@ export default connectState(
|
||||
sync: state.sync,
|
||||
notifications: state.notifications
|
||||
};
|
||||
},
|
||||
true
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { ClientboundNotification } from "revolt.js/dist/websocket/notifications";
|
||||
import { WithDispatcher } from "../../redux/reducers";
|
||||
import { Client, Message } from "revolt.js/dist";
|
||||
import {
|
||||
ClientOperations,
|
||||
ClientStatus
|
||||
} from "./RevoltClient";
|
||||
import { StateUpdater } from "preact/hooks";
|
||||
import { dispatch } from "../../redux";
|
||||
|
||||
export var preventReconnect = false;
|
||||
let preventUntil = 0;
|
||||
@@ -15,9 +15,8 @@ export function setReconnectDisallowed(allowed: boolean) {
|
||||
}
|
||||
|
||||
export function registerEvents({
|
||||
operations,
|
||||
dispatcher
|
||||
}: { operations: ClientOperations } & WithDispatcher, setStatus: StateUpdater<ClientStatus>, client: Client) {
|
||||
operations
|
||||
}: { operations: ClientOperations }, setStatus: StateUpdater<ClientStatus>, client: Client) {
|
||||
function attemptReconnect() {
|
||||
if (preventReconnect) return;
|
||||
function reconnect() {
|
||||
@@ -47,7 +46,7 @@ export function registerEvents({
|
||||
switch (packet.type) {
|
||||
case "ChannelStartTyping": {
|
||||
if (packet.user === client.user?._id) return;
|
||||
dispatcher({
|
||||
dispatch({
|
||||
type: "TYPING_START",
|
||||
channel: packet.id,
|
||||
user: packet.user
|
||||
@@ -56,7 +55,7 @@ export function registerEvents({
|
||||
}
|
||||
case "ChannelStopTyping": {
|
||||
if (packet.user === client.user?._id) return;
|
||||
dispatcher({
|
||||
dispatch({
|
||||
type: "TYPING_STOP",
|
||||
channel: packet.id,
|
||||
user: packet.user
|
||||
@@ -64,7 +63,7 @@ export function registerEvents({
|
||||
break;
|
||||
}
|
||||
case "ChannelAck": {
|
||||
dispatcher({
|
||||
dispatch({
|
||||
type: "UNREADS_MARK_READ",
|
||||
channel: packet.id,
|
||||
message: packet.message_id
|
||||
@@ -76,7 +75,7 @@ export function registerEvents({
|
||||
|
||||
message: (message: Message) => {
|
||||
if (message.mentions?.includes(client.user!._id)) {
|
||||
dispatcher({
|
||||
dispatch({
|
||||
type: "UNREADS_MENTION",
|
||||
channel: message.channel,
|
||||
message: message._id
|
||||
|
||||
Reference in New Issue
Block a user