Fix ESLint issues
This commit is contained in:
@@ -1,23 +1,26 @@
|
|||||||
import js from '@eslint/js'
|
import js from "@eslint/js";
|
||||||
import globals from 'globals'
|
import globals from "globals";
|
||||||
import reactHooks from 'eslint-plugin-react-hooks'
|
import reactHooks from "eslint-plugin-react-hooks";
|
||||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
import reactRefresh from "eslint-plugin-react-refresh";
|
||||||
import tseslint from 'typescript-eslint'
|
import tseslint from "typescript-eslint";
|
||||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
import { defineConfig, globalIgnores } from "eslint/config";
|
||||||
|
|
||||||
export default defineConfig([
|
export default defineConfig([
|
||||||
globalIgnores(['dist']),
|
globalIgnores(["dist"]),
|
||||||
{
|
{
|
||||||
files: ['**/*.{ts,tsx}'],
|
files: ["**/*.{ts,tsx}"],
|
||||||
extends: [
|
extends: [
|
||||||
js.configs.recommended,
|
js.configs.recommended,
|
||||||
tseslint.configs.recommended,
|
tseslint.configs.recommended,
|
||||||
reactHooks.configs['recommended-latest'],
|
reactHooks.configs["recommended-latest"],
|
||||||
reactRefresh.configs.vite,
|
reactRefresh.configs.vite,
|
||||||
],
|
],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
ecmaVersion: 2020,
|
ecmaVersion: 2020,
|
||||||
globals: globals.browser,
|
globals: globals.browser,
|
||||||
},
|
},
|
||||||
|
rules: {
|
||||||
|
"react-refresh/only-export-components": "off",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
])
|
]);
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ function SyncThreadStatus(): React.ReactElement {
|
|||||||
const interval = setInterval(loadStatus, 1000);
|
const interval = setInterval(loadStatus, 1000);
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, []);
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,64 +1,34 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { JsonView, darkStyles } from "react-json-view-lite";
|
import { JsonView, darkStyles } from "react-json-view-lite";
|
||||||
import "react-json-view-lite/dist/index.css";
|
import "react-json-view-lite/dist/index.css";
|
||||||
import { WsApi, type WsMessage } from "../api/WsApi";
|
import { type WsMessage } from "../api/WsApi";
|
||||||
import { useSnackbar } from "../hooks/contexts_provider/SnackbarProvider";
|
|
||||||
import { time } from "../utils/DateUtils";
|
|
||||||
import { useUserInfo } from "../widgets/dashboard/BaseAuthenticatedPage";
|
import { useUserInfo } from "../widgets/dashboard/BaseAuthenticatedPage";
|
||||||
import { MatrixGWRouteContainer } from "../widgets/MatrixGWRouteContainer";
|
import { MatrixGWRouteContainer } from "../widgets/MatrixGWRouteContainer";
|
||||||
|
import { MatrixWS, WSState } from "../widgets/messages/MatrixWS";
|
||||||
import { NotLinkedAccountMessage } from "../widgets/NotLinkedAccountMessage";
|
import { NotLinkedAccountMessage } from "../widgets/NotLinkedAccountMessage";
|
||||||
|
|
||||||
const State = {
|
|
||||||
Closed: "Closed",
|
|
||||||
Connected: "Connected",
|
|
||||||
Error: "Error",
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
type TimestampedMessages = WsMessage & { time: number };
|
type TimestampedMessages = WsMessage & { time: number };
|
||||||
|
|
||||||
export function WSDebugRoute(): React.ReactElement {
|
export function WSDebugRoute(): React.ReactElement {
|
||||||
const user = useUserInfo();
|
const user = useUserInfo();
|
||||||
if (!user.info.matrix_account_connected) return <NotLinkedAccountMessage />;
|
|
||||||
|
|
||||||
const snackbar = useSnackbar();
|
|
||||||
|
|
||||||
const [state, setState] = React.useState<string>(State.Closed);
|
|
||||||
const wsRef = React.useRef<WebSocket | undefined>(undefined);
|
|
||||||
|
|
||||||
|
const [state, setState] = React.useState<string>(WSState.Closed);
|
||||||
const [messages, setMessages] = React.useState<TimestampedMessages[]>([]);
|
const [messages, setMessages] = React.useState<TimestampedMessages[]>([]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
const handleMessage = (msg: WsMessage) => {
|
||||||
const ws = new WebSocket(WsApi.WsURL);
|
setMessages((l) => [...l, msg]);
|
||||||
wsRef.current = ws;
|
};
|
||||||
|
|
||||||
ws.onopen = () => setState(State.Connected);
|
if (!user.info.matrix_account_connected) return <NotLinkedAccountMessage />;
|
||||||
ws.onerror = (e) => {
|
|
||||||
console.error(`WS Debug error!`, e);
|
|
||||||
snackbar(`WebSocket error! ${e}`);
|
|
||||||
setState(State.Error);
|
|
||||||
};
|
|
||||||
ws.onclose = () => {
|
|
||||||
setState(State.Closed);
|
|
||||||
wsRef.current = undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
ws.onmessage = (msg) => {
|
|
||||||
const dec = JSON.parse(msg.data);
|
|
||||||
setMessages((l) => {
|
|
||||||
return [{ time: time(), ...dec }, ...l];
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return () => ws.close();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MatrixGWRouteContainer label={"WebSocket Debug"}>
|
<MatrixGWRouteContainer label={"WebSocket Debug"}>
|
||||||
<div>
|
<div>
|
||||||
State:{" "}
|
State:{" "}
|
||||||
<span style={{ color: state == State.Connected ? "green" : "red" }}>
|
<span style={{ color: state == WSState.Connected ? "green" : "red" }}>
|
||||||
{state}
|
{state}
|
||||||
</span>
|
</span>
|
||||||
|
<MatrixWS onStateChange={setState} onMessage={handleMessage} />
|
||||||
</div>
|
</div>
|
||||||
{messages.map((msg, id) => (
|
{messages.map((msg, id) => (
|
||||||
<div style={{ margin: "10px", backgroundColor: "black" }}>
|
<div style={{ margin: "10px", backgroundColor: "black" }}>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { svgIconClasses } from "@mui/material/SvgIcon";
|
|||||||
import { typographyClasses } from "@mui/material/Typography";
|
import { typographyClasses } from "@mui/material/Typography";
|
||||||
import { gray, green, red } from "../themePrimitives";
|
import { gray, green, red } from "../themePrimitives";
|
||||||
|
|
||||||
/* eslint-disable import/prefer-default-export */
|
|
||||||
export const dataDisplayCustomizations: Components<Theme> = {
|
export const dataDisplayCustomizations: Components<Theme> = {
|
||||||
MuiList: {
|
MuiList: {
|
||||||
styleOverrides: {
|
styleOverrides: {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { type Theme, alpha, type Components } from "@mui/material/styles";
|
import { type Theme, alpha, type Components } from "@mui/material/styles";
|
||||||
import { gray, orange } from "../themePrimitives";
|
import { gray, orange } from "../themePrimitives";
|
||||||
|
|
||||||
/* eslint-disable import/prefer-default-export */
|
|
||||||
export const feedbackCustomizations: Components<Theme> = {
|
export const feedbackCustomizations: Components<Theme> = {
|
||||||
MuiAlert: {
|
MuiAlert: {
|
||||||
styleOverrides: {
|
styleOverrides: {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import CheckRoundedIcon from "@mui/icons-material/CheckRounded";
|
|||||||
import RemoveRoundedIcon from "@mui/icons-material/RemoveRounded";
|
import RemoveRoundedIcon from "@mui/icons-material/RemoveRounded";
|
||||||
import { gray, brand } from "../themePrimitives";
|
import { gray, brand } from "../themePrimitives";
|
||||||
|
|
||||||
/* eslint-disable import/prefer-default-export */
|
|
||||||
export const inputsCustomizations: Components<Theme> = {
|
export const inputsCustomizations: Components<Theme> = {
|
||||||
MuiButtonBase: {
|
MuiButtonBase: {
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { tabClasses } from "@mui/material/Tab";
|
|||||||
import UnfoldMoreRoundedIcon from "@mui/icons-material/UnfoldMoreRounded";
|
import UnfoldMoreRoundedIcon from "@mui/icons-material/UnfoldMoreRounded";
|
||||||
import { gray, brand } from "../themePrimitives";
|
import { gray, brand } from "../themePrimitives";
|
||||||
|
|
||||||
/* eslint-disable import/prefer-default-export */
|
|
||||||
export const navigationCustomizations: Components<Theme> = {
|
export const navigationCustomizations: Components<Theme> = {
|
||||||
MuiMenuItem: {
|
MuiMenuItem: {
|
||||||
styleOverrides: {
|
styleOverrides: {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { alpha, type Theme, type Components } from "@mui/material/styles";
|
import { alpha, type Theme, type Components } from "@mui/material/styles";
|
||||||
import { gray } from "../themePrimitives";
|
import { gray } from "../themePrimitives";
|
||||||
|
|
||||||
/* eslint-disable import/prefer-default-export */
|
|
||||||
export const surfacesCustomizations: Components<Theme> = {
|
export const surfacesCustomizations: Components<Theme> = {
|
||||||
MuiAccordion: {
|
MuiAccordion: {
|
||||||
defaultProps: {
|
defaultProps: {
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ declare module "@mui/material/styles" {
|
|||||||
900: string;
|
900: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PaletteColor extends ColorRange {}
|
|
||||||
|
|
||||||
interface Palette {
|
interface Palette {
|
||||||
baseShadow: string;
|
baseShadow: string;
|
||||||
}
|
}
|
||||||
@@ -405,10 +403,10 @@ export const shape = {
|
|||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const defaultShadows: Shadows = [
|
const defaultShadows: Shadows = [
|
||||||
"none",
|
"none",
|
||||||
"var(--template-palette-baseShadow)",
|
"var(--template-palette-baseShadow)",
|
||||||
...defaultTheme.shadows.slice(2),
|
...defaultTheme.shadows.slice(2),
|
||||||
];
|
] as never;
|
||||||
|
|
||||||
export const shadows = defaultShadows;
|
export const shadows = defaultShadows;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const State = {
|
|||||||
type State = keyof typeof State;
|
type State = keyof typeof State;
|
||||||
|
|
||||||
export function AsyncWidget(p: {
|
export function AsyncWidget(p: {
|
||||||
loadKey: any;
|
loadKey: unknown;
|
||||||
load: () => Promise<void>;
|
load: () => Promise<void>;
|
||||||
errMsg: string;
|
errMsg: string;
|
||||||
build: () => React.ReactElement;
|
build: () => React.ReactElement;
|
||||||
@@ -19,7 +19,7 @@ export function AsyncWidget(p: {
|
|||||||
}): React.ReactElement {
|
}): React.ReactElement {
|
||||||
const [state, setState] = useState<number>(State.Loading);
|
const [state, setState] = useState<number>(State.Loading);
|
||||||
|
|
||||||
const counter = useRef<any>(null);
|
const counter = useRef<unknown>(null);
|
||||||
|
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user