From 843e03b42c7a33ba081be7ccde50f08c8f8d4812 Mon Sep 17 00:00:00 2001
From: AAGaming <aa@mail.catvibers.me>
Date: Sun, 4 Sep 2022 22:14:35 -0400
Subject: fix(toaster): allow toasts to show ingame

---
 frontend/src/components/Toast.tsx | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

(limited to 'frontend/src/components/Toast.tsx')

diff --git a/frontend/src/components/Toast.tsx b/frontend/src/components/Toast.tsx
index 559c37c6..9a74eb5d 100644
--- a/frontend/src/components/Toast.tsx
+++ b/frontend/src/components/Toast.tsx
@@ -1,5 +1,5 @@
-import { ToastData, findModule, joinClassNames } from 'decky-frontend-lib';
-import { FunctionComponent } from 'react';
+import { ToastData, findModule, findModuleChild, joinClassNames } from 'decky-frontend-lib';
+import { FunctionComponent, useEffect } from 'react';
 
 interface ToastProps {
   toast: {
@@ -28,7 +28,21 @@ const templateClasses = findModule((mod) => {
   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 composition = useComposition(2); // 2: overlay
+  useEffect(() => {
+    return () => {
+      composition.releaseComposition();
+    };
+  }, []);
   return (
     <div
       style={{ '--toast-duration': `${toast.nToastDurationMS}ms` } as React.CSSProperties}
-- 
cgit v1.2.3

