diff options
| author | AAGaming <aa@mail.catvibers.me> | 2022-09-04 13:33:42 -0400 |
|---|---|---|
| committer | AAGaming <aa@mail.catvibers.me> | 2022-09-04 13:33:42 -0400 |
| commit | acaf6c72e48e2bbb42b921292d49c1d157306d0b (patch) | |
| tree | 0a93c06a0cb01186edde9bfdef5aace71308ae54 /frontend/src/toaster.tsx | |
| parent | eb439574becb9a82c283d513a98440d7c8efbafe (diff) | |
| download | decky-loader-acaf6c72e48e2bbb42b921292d49c1d157306d0b.tar.gz decky-loader-acaf6c72e48e2bbb42b921292d49c1d157306d0b.zip | |
Update decky-frontend-lib and refactor patches
Diffstat (limited to 'frontend/src/toaster.tsx')
| -rw-r--r-- | frontend/src/toaster.tsx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/frontend/src/toaster.tsx b/frontend/src/toaster.tsx index 04f1556e..f42eb3f5 100644 --- a/frontend/src/toaster.tsx +++ b/frontend/src/toaster.tsx @@ -1,4 +1,4 @@ -import { ToastData, afterPatch, findInReactTree, findModuleChild, sleep, unpatch } from 'decky-frontend-lib'; +import { Patch, ToastData, afterPatch, findInReactTree, findModuleChild, sleep } from 'decky-frontend-lib'; import Toast from './components/Toast'; import Logger from './logger'; @@ -11,7 +11,7 @@ declare global { } class Toaster extends Logger { - private instanceRet: any; + private instanceRetPatch?: Patch; private node: any; private settingsModule: any; @@ -46,8 +46,7 @@ class Toaster extends Logger { this.node.stateNode.render = (...args: any[]) => { const ret = this.node.stateNode.__proto__.render.call(this.node.stateNode, ...args); if (ret) { - this.instanceRet = ret; - afterPatch(ret, 'type', (_: any, ret: any) => { + this.instanceRetPatch = afterPatch(ret, 'type', (_: any, ret: any) => { if (ret?.props?.children[1]?.children?.props?.notification?.decky) { const toast = ret.props.children[1].children.props.notification; ret.props.children[1].children.type = () => <Toast toast={toast} />; @@ -84,7 +83,7 @@ class Toaster extends Logger { } deinit() { - this.instanceRet && unpatch(this.instanceRet, 'type'); + this.instanceRetPatch?.unpatch(); this.node && delete this.node.stateNode.render; this.node && this.node.stateNode.forceUpdate(); } |
