mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 16:51:58 +00:00
fix(toaster): allow toasts to show ingame
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { ToastData, findModule, joinClassNames } from 'decky-frontend-lib';
|
import { ToastData, findModule, findModuleChild, joinClassNames } from 'decky-frontend-lib';
|
||||||
import { FunctionComponent } from 'react';
|
import { FunctionComponent, useEffect } from 'react';
|
||||||
|
|
||||||
interface ToastProps {
|
interface ToastProps {
|
||||||
toast: {
|
toast: {
|
||||||
@@ -28,7 +28,21 @@ const templateClasses = findModule((mod) => {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const useComposition = findModuleChild((m: any) => {
|
||||||
|
if (typeof m !== 'object') return false;
|
||||||
|
for (let prop in m) {
|
||||||
|
if (m[prop]?.toString()?.includes('.Get().ChangeMinimumCompositionStateRequest')) return m[prop];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
const Toast: FunctionComponent<ToastProps> = ({ toast }) => {
|
const Toast: FunctionComponent<ToastProps> = ({ toast }) => {
|
||||||
|
const composition = useComposition(2); // 2: overlay
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
composition.releaseComposition();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{ '--toast-duration': `${toast.nToastDurationMS}ms` } as React.CSSProperties}
|
style={{ '--toast-duration': `${toast.nToastDurationMS}ms` } as React.CSSProperties}
|
||||||
|
|||||||
Reference in New Issue
Block a user