fix(Utils): return null when SP not found

This commit is contained in:
Mikhail Kozlov
2023-05-18 11:41:45 -07:00
parent 3ca8c43a54
commit 18d341f82a

View File

@@ -22,7 +22,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;
}
/**
@@ -38,5 +38,5 @@ export function getFocusNavController(): any {
export function getGamepadNavigationTrees(): any {
const focusNav = getFocusNavController();
const context = focusNav.m_ActiveContext || focusNav.m_LastActiveContext;
return context.m_rgGamepadNavigationTrees;
return context?.m_rgGamepadNavigationTrees;
}