mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 13:01:59 +00:00
Use a conditional while loop for when the scroll root is not found. (#212)
* Changed back to a while loop for grabbing the scroll root\nAs recursive function exits before it hits 30 iterations in testing. * Changed so if recursive limit is hit, it returns null instead of attempting to continue. * Added log messages regarding recursion limits, as well as fixed recursion tracking. * Removed errant return remaining from scroll root check.
This commit is contained in:
@@ -49,23 +49,29 @@ class TabsHook extends Logger {
|
|||||||
let scrollRoot: any;
|
let scrollRoot: any;
|
||||||
async function findScrollRoot(currentNode: any, iters: number): Promise<any> {
|
async function findScrollRoot(currentNode: any, iters: number): Promise<any> {
|
||||||
if (iters >= 30) {
|
if (iters >= 30) {
|
||||||
await sleep(5000);
|
self.error(
|
||||||
return await findScrollRoot(tree, 0);
|
'Scroll root was not found before hitting the recursion limit, a developer will need to increase the limit.',
|
||||||
|
);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
currentNode = currentNode?.child;
|
currentNode = currentNode?.child;
|
||||||
if (currentNode?.type?.prototype?.RemoveSmartScrollContainer) return currentNode;
|
if (currentNode?.type?.prototype?.RemoveSmartScrollContainer) {
|
||||||
|
self.log(`Scroll root was found in ${iters} recursion cycles`);
|
||||||
|
return currentNode;
|
||||||
|
}
|
||||||
if (!currentNode) return null;
|
if (!currentNode) return null;
|
||||||
if (currentNode.sibling) {
|
if (currentNode.sibling) {
|
||||||
let node = await findScrollRoot(currentNode.sibling, iters++);
|
let node = await findScrollRoot(currentNode.sibling, iters + 1);
|
||||||
if (node !== null) return node;
|
if (node !== null) return node;
|
||||||
}
|
}
|
||||||
return await findScrollRoot(currentNode, iters++);
|
return await findScrollRoot(currentNode, iters + 1);
|
||||||
}
|
}
|
||||||
(async () => {
|
(async () => {
|
||||||
scrollRoot = await findScrollRoot(tree, 0);
|
scrollRoot = await findScrollRoot(tree, 0);
|
||||||
if (!scrollRoot) {
|
while (!scrollRoot) {
|
||||||
this.error('Failed to find scroll root node!');
|
this.log('Failed to find scroll root node, reattempting in 5 seconds');
|
||||||
return;
|
await sleep(5000);
|
||||||
|
scrollRoot = await findScrollRoot(tree, 0);
|
||||||
}
|
}
|
||||||
let newQA: any;
|
let newQA: any;
|
||||||
let newQATabRenderer: any;
|
let newQATabRenderer: any;
|
||||||
|
|||||||
Reference in New Issue
Block a user