summaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2022-10-14 20:09:11 -0400
committerGitHub <noreply@github.com>2022-10-14 17:09:11 -0700
commit3ac0abc82bd266eecb7c5f468481e364790be665 (patch)
tree46420533b8936b12c925818054aca37373f4dcb4 /frontend/src
parent618abec97ade612966ed7cae52a0fd7b6efc8863 (diff)
downloaddecky-loader-3ac0abc82bd266eecb7c5f468481e364790be665.tar.gz
decky-loader-3ac0abc82bd266eecb7c5f468481e364790be665.zip
Rewrite toaster hook to not re-create the window (#217)v2.2.4-pre1
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/components/Toast.tsx2
-rw-r--r--frontend/src/toaster.tsx37
2 files changed, 14 insertions, 25 deletions
diff --git a/frontend/src/components/Toast.tsx b/frontend/src/components/Toast.tsx
index 559c37c6..01a436d7 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={joinClassNames(toastClasses.ToastPopup, toastClasses.toastEnter)}
+ className={toastClasses.toastEnter}
>
<div
onClick={toast.data.onClick}
diff --git a/frontend/src/toaster.tsx b/frontend/src/toaster.tsx
index 8eea35bc..1d3d66a9 100644
--- a/frontend/src/toaster.tsx
+++ b/frontend/src/toaster.tsx
@@ -38,34 +38,23 @@ class Toaster extends Logger {
await sleep(2000);
}
- this.node = instance.return.return;
+ this.node = instance.sibling.child;
let toast: any;
let renderedToast: ReactNode = 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;
- });
+ 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;
}
return ret;
- };
- this.node.stateNode.forceUpdate();
+ });
this.settingsModule = findModuleChild((m) => {
if (typeof m !== 'object') return undefined;
for (let prop in m) {