From e6df308668641bd8a2b96232bad97761144d97ff Mon Sep 17 00:00:00 2001 From: 12944qwerty Date: Sat, 26 Oct 2024 00:40:49 -0400 Subject: [PATCH] lint --- .eslintrc.yml | 3 + .../coremods/settings/pages/QuickCSS.tsx | 70 ++++++++++++------- 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 1d9d7452b..3fbd25aeb 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -29,6 +29,9 @@ rules: node/no-unpublished-import: off node/no-unpublished-require: off node/shebang: off + node/no-extraneous-import: + - error + - allowModules: ["lodash"] no-process-exit: off no-undef: off no-undefined: off diff --git a/src/renderer/coremods/settings/pages/QuickCSS.tsx b/src/renderer/coremods/settings/pages/QuickCSS.tsx index 8f484f3b4..4b4e5b8eb 100644 --- a/src/renderer/coremods/settings/pages/QuickCSS.tsx +++ b/src/renderer/coremods/settings/pages/QuickCSS.tsx @@ -25,9 +25,17 @@ type ThemeModule = { removeChangeListener: (listener: () => unknown) => unknown; }; +type PopoutWindowType = React.ComponentType<{ + ref: React.RefObject; + withTitleBar: boolean; + windowKey: string; + title: string; + children: React.ReactNode; +}>; + const PopoutModule = await webpack.waitForModule( webpack.filters.bySource('type:"POPOUT_WINDOW_OPEN"'), -)!; +); const openPopout = webpack.getFunctionBySource< (key: string, render: React.ComponentType, features: Record) => void >(PopoutModule, "POPOUT_WINDOW_OPEN")!; @@ -46,7 +54,9 @@ const PopoutWindowStore = webpack.getByStoreName< getIsAlwaysOnTop: (key: string) => boolean; } >("PopoutWindowStore")!; -let PopoutWindow = webpack.getBySource(".EMBEDDED_ACTIVITIES_ARE_YOU_SURE_WANT_TO_LEAVE"); +let PopoutWindow = webpack.getBySource( + ".EMBEDDED_ACTIVITIES_ARE_YOU_SURE_WANT_TO_LEAVE", +); function useTheme(): "light" | "dark" { const [theme, setTheme] = React.useState<"light" | "dark">("dark"); @@ -202,29 +212,33 @@ const QuickCSS = (props: { popout: boolean } & Record): React.R el.rel = "stylesheet"; el.href = `replugged://renderer.css?t=${Date.now()}`; window.document.head.appendChild(el); - }, []) + }, []); } const [alwaysOnTop, setAlwaysOnTop_] = React.useState(props.popoutOnTop); return ( <> - {!props.popout ? <> - - {Messages.REPLUGGED_QUICKCSS} -
- {autoApply ? null : ( - - )} - -
-
- - : null} + {!props.popout ? ( + <> + + {Messages.REPLUGGED_QUICKCSS} +
+ {autoApply ? null : ( + + )} + +
+
+ + + ) : null} {!props.popout && props.isPopoutOpen ? ( ): React.R { - if (!PopoutWindow) - PopoutWindow = webpack.getBySource(".EMBEDDED_ACTIVITIES_ARE_YOU_SURE_WANT_TO_LEAVE"); + let PopoutWindowComp: PopoutWindowType; + if (!PopoutWindow) { + PopoutWindowComp = webpack.getBySource( + ".EMBEDDED_ACTIVITIES_ARE_YOU_SURE_WANT_TO_LEAVE", + )!; + } else { + PopoutWindowComp = PopoutWindow; + } openPopout( "DISCORD_REPLUGGED_QUICKCSS", () => ( - - + ), {}, ); @@ -279,7 +299,7 @@ const QuickCSS = (props: { popout: boolean } & Record): React.R ); }; -console.log("omg") + export const ConnectedQuickCSS = flux.connectStores< { popout: boolean }, { popout: boolean; isPopoutOpen: boolean }