mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-06 13:18:27 +02:00
Show stats in the Guide menu & refactor
This commit is contained in:
23
src/index.ts
23
src/index.ts
@@ -1,5 +1,5 @@
|
||||
import "@utils/global";
|
||||
import { BxEvent } from "@utils/bx-event";
|
||||
import { BxEvent, XcloudGuideWhere } from "@utils/bx-event";
|
||||
import { BX_FLAGS } from "@utils/bx-flags";
|
||||
import { BxExposed } from "@utils/bx-exposed";
|
||||
import { t } from "@utils/translation";
|
||||
@@ -185,7 +185,7 @@ window.addEventListener(BxEvent.STREAM_STOPPED, e => {
|
||||
|
||||
STATES.currentStream.audioGainNode = null;
|
||||
STATES.currentStream.$video = null;
|
||||
StreamStats.onStoppedPlaying();
|
||||
StreamStats.getInstance().onStoppedPlaying();
|
||||
|
||||
MouseCursorHider.stop();
|
||||
TouchController.reset();
|
||||
@@ -206,6 +206,25 @@ function observeRootDialog($root: HTMLElement) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mutation.addedNodes.length === 1) {
|
||||
const $addedElm = mutation.addedNodes[0];
|
||||
if ($addedElm instanceof HTMLElement && $addedElm.className) {
|
||||
if ($addedElm.className.startsWith('NavigationAnimation') || $addedElm.className.startsWith('DialogRoutes') || $addedElm.className.startsWith('Dialog-module__container')) {
|
||||
// Find navigation bar
|
||||
const $selectedTab = $addedElm.querySelector('div[class^=NavigationMenu] button[aria-selected=true');
|
||||
if ($selectedTab) {
|
||||
let $elm: Element | null = $selectedTab;
|
||||
let index;
|
||||
for (index = 0; ($elm = $elm?.previousElementSibling); index++);
|
||||
|
||||
if (index === 0) {
|
||||
BxEvent.dispatch(window, BxEvent.XCLOUD_GUIDE_SHOWN, {where: XcloudGuideWhere.HOME});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const shown = ($root.firstElementChild && $root.firstElementChild.childElementCount > 0) || false;
|
||||
if (shown !== currentShown) {
|
||||
currentShown = shown;
|
||||
|
Reference in New Issue
Block a user