diff options
| author | AAGaming <aa@mail.catvibers.me> | 2022-10-14 22:41:46 -0400 |
|---|---|---|
| committer | AAGaming <aa@mail.catvibers.me> | 2022-10-14 22:41:46 -0400 |
| commit | 7445f066ed53c3b6e8a1003649ea21bff749b728 (patch) | |
| tree | 8a8c9dc792a77849978d8cce0485f23ee10aa40d /frontend/src | |
| parent | 6e48aefce863e316edeaa75e3e14cb516de053f2 (diff) | |
| download | decky-loader-7445f066ed53c3b6e8a1003649ea21bff749b728.tar.gz decky-loader-7445f066ed53c3b6e8a1003649ea21bff749b728.zip | |
Revert "Rewrite toaster hook to not re-create the window (#217)"
This reverts commit 3ac0abc82bd266eecb7c5f468481e364790be665.
Diffstat (limited to 'frontend/src')
| -rw-r--r-- | frontend/src/components/Toast.tsx | 2 | ||||
| -rw-r--r-- | frontend/src/toaster.tsx | 37 |
2 files changed, 25 insertions, 14 deletions
diff --git a/frontend/src/components/Toast.tsx b/frontend/src/components/Toast.tsx index 01a436d7..559c37c6 100644 --- a/frontend/src/components/Toast.tsx +++ b/frontend/src/components/Toast.tsx @@ -32,7 +32,7 @@ const Toast: FunctionComponent<ToastProps> = ({ toast }) => { return ( <div style={{ '--toast-duration': `${toast.nToastDurationMS}ms` } as React.CSSProperties} - className={toastClasses.toastEnter} + className={joinClassNames(toastClasses.ToastPopup, toastClasses.toastEnter)} > <div onClick={toast.data.onClick} diff --git a/frontend/src/toaster.tsx b/frontend/src/toaster.tsx index 1d3d66a9..8eea35bc 100644 --- a/frontend/src/toaster.tsx +++ b/frontend/src/toaster.tsx @@ -38,23 +38,34 @@ class Toaster extends Logger { await sleep(2000); } - this.node = instance.sibling.child; + this.node = instance.return.return; let toast: any; let renderedToast: ReactNode = null; - afterPatch(this.node, 'type', (args: any[], ret: any) => { - const currentToast = args[0].notification; - if (currentToast?.decky) { - if (currentToast !== toast) { - toast = currentToast; - renderedToast = <Toast toast={toast} />; - } - ret.props.children = renderedToast; - } else { - toast = null; - renderedToast = null; + this.node.stateNode.render = (...args: any[]) => { + const ret = this.node.stateNode.__proto__.render.call(this.node.stateNode, ...args); + if (ret) { + this.instanceRetPatch = afterPatch(ret, 'type', (_: any, ret: any) => { + if (ret?.props?.children[1]?.children?.props) { + const currentToast = ret.props.children[1].children.props.notification; + if (currentToast?.decky) { + if (currentToast == toast) { + ret.props.children[1].children = renderedToast; + } else { + toast = currentToast; + renderedToast = <Toast toast={toast} />; + ret.props.children[1].children = renderedToast; + } + } else { + toast = null; + renderedToast = null; + } + } + return ret; + }); } return ret; - }); + }; + this.node.stateNode.forceUpdate(); this.settingsModule = findModuleChild((m) => { if (typeof m !== 'object') return undefined; for (let prop in m) { |
