diff --git a/matrixgw_frontend/eslint.config.js b/matrixgw_frontend/eslint.config.js index b19330b..2606d73 100644 --- a/matrixgw_frontend/eslint.config.js +++ b/matrixgw_frontend/eslint.config.js @@ -1,23 +1,26 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' -import { defineConfig, globalIgnores } from 'eslint/config' +import js from "@eslint/js"; +import globals from "globals"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; +import tseslint from "typescript-eslint"; +import { defineConfig, globalIgnores } from "eslint/config"; export default defineConfig([ - globalIgnores(['dist']), + globalIgnores(["dist"]), { - files: ['**/*.{ts,tsx}'], + files: ["**/*.{ts,tsx}"], extends: [ js.configs.recommended, tseslint.configs.recommended, - reactHooks.configs['recommended-latest'], + reactHooks.configs["recommended-latest"], reactRefresh.configs.vite, ], languageOptions: { ecmaVersion: 2020, globals: globals.browser, }, + rules: { + "react-refresh/only-export-components": "off", + }, }, -]) +]); diff --git a/matrixgw_frontend/src/routes/MatrixLinkRoute.tsx b/matrixgw_frontend/src/routes/MatrixLinkRoute.tsx index 1c57e5b..0125fad 100644 --- a/matrixgw_frontend/src/routes/MatrixLinkRoute.tsx +++ b/matrixgw_frontend/src/routes/MatrixLinkRoute.tsx @@ -257,7 +257,7 @@ function SyncThreadStatus(): React.ReactElement { const interval = setInterval(loadStatus, 1000); return () => clearInterval(interval); - }, []); + }); return ( <> diff --git a/matrixgw_frontend/src/routes/WSDebugRoute.tsx b/matrixgw_frontend/src/routes/WSDebugRoute.tsx index fa6fb67..b572c3a 100644 --- a/matrixgw_frontend/src/routes/WSDebugRoute.tsx +++ b/matrixgw_frontend/src/routes/WSDebugRoute.tsx @@ -1,64 +1,34 @@ import React from "react"; import { JsonView, darkStyles } from "react-json-view-lite"; import "react-json-view-lite/dist/index.css"; -import { WsApi, type WsMessage } from "../api/WsApi"; -import { useSnackbar } from "../hooks/contexts_provider/SnackbarProvider"; -import { time } from "../utils/DateUtils"; +import { type WsMessage } from "../api/WsApi"; import { useUserInfo } from "../widgets/dashboard/BaseAuthenticatedPage"; import { MatrixGWRouteContainer } from "../widgets/MatrixGWRouteContainer"; +import { MatrixWS, WSState } from "../widgets/messages/MatrixWS"; import { NotLinkedAccountMessage } from "../widgets/NotLinkedAccountMessage"; -const State = { - Closed: "Closed", - Connected: "Connected", - Error: "Error", -} as const; - type TimestampedMessages = WsMessage & { time: number }; export function WSDebugRoute(): React.ReactElement { const user = useUserInfo(); - if (!user.info.matrix_account_connected) return ; - - const snackbar = useSnackbar(); - - const [state, setState] = React.useState(State.Closed); - const wsRef = React.useRef(undefined); + const [state, setState] = React.useState(WSState.Closed); const [messages, setMessages] = React.useState([]); - React.useEffect(() => { - const ws = new WebSocket(WsApi.WsURL); - wsRef.current = ws; + const handleMessage = (msg: WsMessage) => { + setMessages((l) => [...l, msg]); + }; - ws.onopen = () => setState(State.Connected); - 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(); - }, []); + if (!user.info.matrix_account_connected) return ; return (
State:{" "} - + {state} +
{messages.map((msg, id) => (
diff --git a/matrixgw_frontend/src/theme/customizations/dataDisplay.tsx b/matrixgw_frontend/src/theme/customizations/dataDisplay.tsx index c23166a..a3ba6b6 100644 --- a/matrixgw_frontend/src/theme/customizations/dataDisplay.tsx +++ b/matrixgw_frontend/src/theme/customizations/dataDisplay.tsx @@ -6,7 +6,6 @@ import { svgIconClasses } from "@mui/material/SvgIcon"; import { typographyClasses } from "@mui/material/Typography"; import { gray, green, red } from "../themePrimitives"; -/* eslint-disable import/prefer-default-export */ export const dataDisplayCustomizations: Components = { MuiList: { styleOverrides: { diff --git a/matrixgw_frontend/src/theme/customizations/feedback.tsx b/matrixgw_frontend/src/theme/customizations/feedback.tsx index b8dc04b..29a7e94 100644 --- a/matrixgw_frontend/src/theme/customizations/feedback.tsx +++ b/matrixgw_frontend/src/theme/customizations/feedback.tsx @@ -1,7 +1,6 @@ import { type Theme, alpha, type Components } from "@mui/material/styles"; import { gray, orange } from "../themePrimitives"; -/* eslint-disable import/prefer-default-export */ export const feedbackCustomizations: Components = { MuiAlert: { styleOverrides: { diff --git a/matrixgw_frontend/src/theme/customizations/inputs.tsx b/matrixgw_frontend/src/theme/customizations/inputs.tsx index d30fcf2..21c2b09 100644 --- a/matrixgw_frontend/src/theme/customizations/inputs.tsx +++ b/matrixgw_frontend/src/theme/customizations/inputs.tsx @@ -8,7 +8,6 @@ import CheckRoundedIcon from "@mui/icons-material/CheckRounded"; import RemoveRoundedIcon from "@mui/icons-material/RemoveRounded"; import { gray, brand } from "../themePrimitives"; -/* eslint-disable import/prefer-default-export */ export const inputsCustomizations: Components = { MuiButtonBase: { defaultProps: { diff --git a/matrixgw_frontend/src/theme/customizations/navigation.tsx b/matrixgw_frontend/src/theme/customizations/navigation.tsx index 2b1a584..6b5cb2d 100644 --- a/matrixgw_frontend/src/theme/customizations/navigation.tsx +++ b/matrixgw_frontend/src/theme/customizations/navigation.tsx @@ -9,7 +9,6 @@ import { tabClasses } from "@mui/material/Tab"; import UnfoldMoreRoundedIcon from "@mui/icons-material/UnfoldMoreRounded"; import { gray, brand } from "../themePrimitives"; -/* eslint-disable import/prefer-default-export */ export const navigationCustomizations: Components = { MuiMenuItem: { styleOverrides: { diff --git a/matrixgw_frontend/src/theme/customizations/surfaces.ts b/matrixgw_frontend/src/theme/customizations/surfaces.ts index 38bf7ed..9dbe938 100644 --- a/matrixgw_frontend/src/theme/customizations/surfaces.ts +++ b/matrixgw_frontend/src/theme/customizations/surfaces.ts @@ -1,7 +1,6 @@ import { alpha, type Theme, type Components } from "@mui/material/styles"; import { gray } from "../themePrimitives"; -/* eslint-disable import/prefer-default-export */ export const surfacesCustomizations: Components = { MuiAccordion: { defaultProps: { diff --git a/matrixgw_frontend/src/theme/themePrimitives.ts b/matrixgw_frontend/src/theme/themePrimitives.ts index 1e95864..b924844 100644 --- a/matrixgw_frontend/src/theme/themePrimitives.ts +++ b/matrixgw_frontend/src/theme/themePrimitives.ts @@ -24,8 +24,6 @@ declare module "@mui/material/styles" { 900: string; } - interface PaletteColor extends ColorRange {} - interface Palette { baseShadow: string; } @@ -405,10 +403,10 @@ export const shape = { borderRadius: 8, }; -// @ts-ignore const defaultShadows: Shadows = [ "none", "var(--template-palette-baseShadow)", ...defaultTheme.shadows.slice(2), -]; +] as never; + export const shadows = defaultShadows; diff --git a/matrixgw_frontend/src/widgets/AsyncWidget.tsx b/matrixgw_frontend/src/widgets/AsyncWidget.tsx index bc7e036..1a4701c 100644 --- a/matrixgw_frontend/src/widgets/AsyncWidget.tsx +++ b/matrixgw_frontend/src/widgets/AsyncWidget.tsx @@ -10,7 +10,7 @@ const State = { type State = keyof typeof State; export function AsyncWidget(p: { - loadKey: any; + loadKey: unknown; load: () => Promise; errMsg: string; build: () => React.ReactElement; @@ -19,7 +19,7 @@ export function AsyncWidget(p: { }): React.ReactElement { const [state, setState] = useState(State.Loading); - const counter = useRef(null); + const counter = useRef(null); const load = async () => { try {