Skip to content

Commit

Permalink
fix(utils): fix potential race condition in findSP
Browse files Browse the repository at this point in the history
  • Loading branch information
AAGaming00 committed Sep 16, 2024
1 parent 3f335b3 commit 3aa07dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
push:
branches:
- v4-dev
- main

jobs:
release:
Expand Down
4 changes: 2 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function findSP(): Window {
if (document.title == 'SP') return window;
// new (SP as popup)
const navTrees = getGamepadNavigationTrees();
return navTrees?.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView;
return navTrees?.find((x: any) => x.m_ID == 'root_1_')?.Root?.Element?.ownerDocument?.defaultView;
}

/**
Expand All @@ -40,6 +40,6 @@ export function getFocusNavController(): any {
*/
export function getGamepadNavigationTrees(): any {
const focusNav = getFocusNavController();
const context = focusNav.m_ActiveContext || focusNav.m_LastActiveContext;
const context = focusNav?.m_ActiveContext || focusNav?.m_LastActiveContext;
return context?.m_rgGamepadNavigationTrees;
}

0 comments on commit 3aa07dc

Please sign in to comment.