diff --git a/src/renderer/coremods/settings/icons/Close.tsx b/src/renderer/coremods/settings/icons/Pin.tsx similarity index 63% rename from src/renderer/coremods/settings/icons/Close.tsx rename to src/renderer/coremods/settings/icons/Pin.tsx index 013f7499c..89a893471 100644 --- a/src/renderer/coremods/settings/icons/Close.tsx +++ b/src/renderer/coremods/settings/icons/Pin.tsx @@ -2,6 +2,9 @@ import { MouseEventHandler } from "react"; export default (props: { onClick?: MouseEventHandler }): React.ReactElement => ( - + -) +); diff --git a/src/renderer/coremods/settings/icons/Unpin.tsx b/src/renderer/coremods/settings/icons/Unpin.tsx new file mode 100644 index 000000000..37511a762 --- /dev/null +++ b/src/renderer/coremods/settings/icons/Unpin.tsx @@ -0,0 +1,14 @@ +import { MouseEventHandler } from "react"; + +export default (props: { onClick?: MouseEventHandler }): React.ReactElement => ( + + + + + + + + + + +); diff --git a/src/renderer/coremods/settings/icons/index.ts b/src/renderer/coremods/settings/icons/index.ts index db6583a38..c704d147c 100644 --- a/src/renderer/coremods/settings/icons/index.ts +++ b/src/renderer/coremods/settings/icons/index.ts @@ -4,8 +4,9 @@ import Link from "./Link"; import Reload from "./Reload"; import Settings from "./Settings"; import Trash from "./Trash"; -import Close from "./Close"; import Popout from "./Popout"; +import Pin from "./Pin"; +import Unpin from "./Unpin"; export default { Discord, @@ -14,6 +15,7 @@ export default { Reload, Settings, Trash, - Close, Popout, + Pin, + Unpin }; diff --git a/src/renderer/coremods/settings/pages/QuickCSS.tsx b/src/renderer/coremods/settings/pages/QuickCSS.tsx index e29dff8cc..efbfc4442 100644 --- a/src/renderer/coremods/settings/pages/QuickCSS.tsx +++ b/src/renderer/coremods/settings/pages/QuickCSS.tsx @@ -11,10 +11,9 @@ import { generalSettings } from "./General"; import { ReactComponent } from "src/types"; import { Store } from "@common/flux"; import Settings from "../icons/Settings"; -import Close from "../icons/Close"; import Popout from "../icons/Popout"; - -const { connectStores } = flux; +import Unpin from "../icons/Unpin"; +import Pin from "../icons/Pin"; interface UseCodeMirrorOptions { value?: string; @@ -42,10 +41,18 @@ const openPopout = webpack.getFunctionBySource(PopoutModule, "POPOUT_WINDOW_OPEN const closePopout = webpack.getFunctionBySource(PopoutModule, "POPOUT_WINDOW_CLOSE") as ( key: string, ) => void; + +// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style +const setAlwaysOnTop = webpack.getFunctionBySource(PopoutModule, "POPOUT_WINDOW_SET_ALWAYS_ON_TOP") as ( + key: string, + alwaysOnTop: boolean, +) => void; + // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style const PopoutWindowStore = webpack.getByStoreName("PopoutWindowStore") as Store & { getWindow: (key: string) => Window; getWindowOpen: (key: string) => boolean; + getIsAlwaysOnTop: (key: string) => boolean; }; // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style @@ -212,6 +219,8 @@ const QuickCSS = (props: { popout: boolean } & Record): React.R }, []); } + const [ alwaysOnTop, setAlwaysOnTop_ ] = React.useState(props.popoutOnTop); + return ( <> {!props.popout ? ( @@ -251,25 +260,28 @@ const QuickCSS = (props: { popout: boolean } & Record): React.R - - {!props.popout ? ( - { - openPopout( - "DISCORD_REPLUGGED_QUICKCSS", - () => ( - - - - ), - {}, - ); - }} /> - ) : ( - { - closePopout("DISCORD_REPLUGGED_QUICKCSS"); - }} /> - )} - + {props.popout ? + {alwaysOnTop ? { + setAlwaysOnTop('DISCORD_REPLUGGED_QUICKCSS', false); + setAlwaysOnTop_(false); + }} /> : { + setAlwaysOnTop('DISCORD_REPLUGGED_QUICKCSS', true); + setAlwaysOnTop_(true); + }} /> + } + : + { + openPopout( + "DISCORD_REPLUGGED_QUICKCSS", + () => ( + + + + ), + {}, + ); + }} /> + }
@@ -278,9 +290,10 @@ const QuickCSS = (props: { popout: boolean } & Record): React.R ); }; -export const ConnectedQuickCSS = connectStores<{ popout: boolean }, { popout: boolean; isPopoutOpen: boolean }>([PopoutWindowStore], (props) => { +export const ConnectedQuickCSS = flux.connectStores<{ popout: boolean }, { popout: boolean; isPopoutOpen: boolean }>([PopoutWindowStore], (props) => { return { isPopoutOpen: PopoutWindowStore.getWindowOpen("DISCORD_REPLUGGED_QUICKCSS"), + popoutOnTop: PopoutWindowStore.getIsAlwaysOnTop("DISCORD_REPLUGGED_QUICKCSS"), ...props } })(QuickCSS);