diff options
| author | AAGaming <aa@mail.catvibers.me> | 2022-12-31 23:27:04 -0500 |
|---|---|---|
| committer | AAGaming <aa@mail.catvibers.me> | 2022-12-31 23:27:04 -0500 |
| commit | 0e5d991c8d33cedea636640c519c8f04b956b37c (patch) | |
| tree | f91de84e8c228ef6e81501d3d968c3c3c203df4b | |
| parent | 0fe3282828e73fc95d0cef4b855a54ec24aa8a9b (diff) | |
| download | decky-loader-aa/menu-hook-api.tar.gz decky-loader-aa/menu-hook-api.zip | |
add patch cachingaa/menu-hook-api
| -rw-r--r-- | frontend/src/menu-hook.tsx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/frontend/src/menu-hook.tsx b/frontend/src/menu-hook.tsx index ad09bc38..810b6dfa 100644 --- a/frontend/src/menu-hook.tsx +++ b/frontend/src/menu-hook.tsx @@ -69,6 +69,7 @@ class MenuHook extends Logger { this.menuRenderer = menuRenderer; this.originalRenderer = menuRenderer.type; let toReplace = new Map<string, ReactNode>(); + let alreadyPatched = new Map<string, { total: number; node: ReactNode }>(); let patchedInnerMenu: any; let overlayComponentManager: any; @@ -132,6 +133,17 @@ class MenuHook extends Logger { toReplace.delete(item?.props.route as string); } if (item?.props?.route && (itemPatches.has(item.props.route as string) || itemPatches.has('*'))) { + if ( + item?.props?.route && + alreadyPatched.has(item.props.route) && + alreadyPatched.get(item.props.route)?.total == + (itemPatches.get(item.props.route)?.size || 0) + (itemPatches.get('*')?.size || 0) + ) { + const patched = alreadyPatched.get(item.props.route); + this.debug('found already patched', patched); + itemList[index] = patched?.node; + return; + } toReplace.set(item?.props?.route as string, itemList[index]); itemPatches.get(item.props.route as string)?.forEach((patch) => { const oType = itemList[index].type; @@ -147,6 +159,10 @@ class MenuHook extends Logger { type: (props: any) => createElement(oType, props), }); }); + alreadyPatched.set(item.props.route, { + total: (itemPatches.get(item.props.route)?.size || 0) + (itemPatches.get('*')?.size || 0), + node: itemList[index], + }); } }); |
