From bace5143d28c42ffcc83509b7fcdf02b6cae6934 Mon Sep 17 00:00:00 2001 From: TrainDoctor Date: Sun, 30 Oct 2022 10:32:05 -0700 Subject: Merge Tabs and Injection Fixes, bring back native Valve toaster (#238) * Bring back component patch-based tabshook * better injection point * finally fix dumb loading error * fix QAM injection breaking after lock * shut up typescript * fix lock screen focusing issues * Bring back the Valve toaster! * Add support for stable steamos * fix focus bug on lock screen but actually * oops: remove extra console log * shut up typescript again * better fix for lockscreen bug * better probably * actually fix focus issues (WTF) Co-authored-by: AAGaming --- .../src/components/QuickAccessVisibleState.tsx | 36 +++++++++------------- frontend/src/components/Toast.tsx | 24 +++++++-------- 2 files changed, 26 insertions(+), 34 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/QuickAccessVisibleState.tsx b/frontend/src/components/QuickAccessVisibleState.tsx index 4df7e1a1..09babe84 100644 --- a/frontend/src/components/QuickAccessVisibleState.tsx +++ b/frontend/src/components/QuickAccessVisibleState.tsx @@ -1,27 +1,21 @@ -import { FC, createContext, useContext, useEffect, useRef, useState } from 'react'; +import { FC, createContext, useContext, useState } from 'react'; const QuickAccessVisibleState = createContext(true); export const useQuickAccessVisible = () => useContext(QuickAccessVisibleState); -export const QuickAccessVisibleStateProvider: FC<{}> = ({ children }) => { - const divRef = useRef(null); - const [visible, setVisible] = useState(false); - useEffect(() => { - const doc: Document | void | null = divRef?.current?.ownerDocument; - if (!doc) return; - setVisible(doc.visibilityState == 'visible'); - const onChange = (e: Event) => { - setVisible(doc.visibilityState == 'visible'); - }; - doc.addEventListener('visibilitychange', onChange); - return () => { - doc.removeEventListener('visibilitychange', onChange); - }; - }, [divRef]); - return ( -
- {children} -
- ); +export const QuickAccessVisibleStateProvider: FC<{ initial: boolean; setter: ((val: boolean) => {}[]) | never[] }> = ({ + children, + initial, + setter, +}) => { + const [visible, setVisible] = useState(initial); + const [prev, setPrev] = useState(initial); + // hack to use an array as a "pointer" to pass the setter up the tree + setter[0] = setVisible; + if (initial != prev) { + setPrev(initial); + setVisible(initial); + } + return {children}; }; diff --git a/frontend/src/components/Toast.tsx b/frontend/src/components/Toast.tsx index e7a220c2..78fb60aa 100644 --- a/frontend/src/components/Toast.tsx +++ b/frontend/src/components/Toast.tsx @@ -27,20 +27,18 @@ const templateClasses = findModule((mod) => { const Toast: FunctionComponent = ({ toast }) => { return ( -
-
- {toast.logo &&
{toast.logo}
} -
-
- {toast.icon &&
{toast.icon}
} -
{toast.title}
-
-
{toast.body}
+
+ {toast.logo &&
{toast.logo}
} +
+
+ {toast.icon &&
{toast.icon}
} +
{toast.title}
+
{toast.body}
); -- cgit v1.2.3