diff options
| author | Devon Schneider <proEndreeper@users.noreply.github.com> | 2022-10-04 12:54:54 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-04 11:54:54 -0700 |
| commit | d58001c323b935f3b8266dd5aade2a9ddc5bee5f (patch) | |
| tree | 3d688c446b11777fa39d6d0608b16f0a333a77a6 /frontend/src | |
| parent | d727ba72f39418ff14fab629b9ea275beadbeeb6 (diff) | |
| download | decky-loader-d58001c323b935f3b8266dd5aade2a9ddc5bee5f.tar.gz decky-loader-d58001c323b935f3b8266dd5aade2a9ddc5bee5f.zip | |
Fixed an issue regarding the scroll root path (#201)v2.2.2-pre1v2.2.1
* Changed so searching for the scroll root node will look through siblings of children nodes.
* Added a missing await
Seem to have missed an await from when I was converting my proof-of-concept to an async function.
* Minor stylistic change
* Changed where program retries to find the scroll root.
Diffstat (limited to 'frontend/src')
| -rw-r--r-- | frontend/src/tabs-hook.ts | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/frontend/src/tabs-hook.ts b/frontend/src/tabs-hook.ts index 65e1b2b4..ac3dac39 100644 --- a/frontend/src/tabs-hook.ts +++ b/frontend/src/tabs-hook.ts @@ -47,18 +47,25 @@ class TabsHook extends Logger { const self = this; const tree = (document.getElementById('root') as any)._reactRootContainer._internalRoot.current; let scrollRoot: any; - let currentNode = tree; + async function findScrollRoot(currentNode: any, iters: number): Promise<any> { + if (iters >= 30) { + await sleep(5000); + return await findScrollRoot(tree, 0); + } + currentNode = currentNode?.child; + if (currentNode?.type?.prototype?.RemoveSmartScrollContainer) return currentNode; + if (!currentNode) return null; + if (currentNode.sibling) { + let node = await findScrollRoot(currentNode.sibling, iters++); + if (node !== null) return node; + } + return await findScrollRoot(currentNode, iters++); + } (async () => { - let iters = 0; - while (!scrollRoot) { - iters++; - currentNode = currentNode?.child; - if (iters >= 30 || !currentNode) { - iters = 0; - currentNode = tree; - await sleep(5000); - } - if (currentNode?.type?.prototype?.RemoveSmartScrollContainer) scrollRoot = currentNode; + scrollRoot = await findScrollRoot(tree, 0); + if (!scrollRoot) { + this.error('Failed to find scroll root node!'); + return; } let newQA: any; let newQATabRenderer: any; |
