Optimize + refactor code

This commit is contained in:
redphx
2024-10-21 20:50:12 +07:00
parent 075b15aa48
commit de76364a46
44 changed files with 1794 additions and 1274 deletions

View File

@@ -9,8 +9,6 @@ import { PrefKey } from "@/enums/pref-keys";
import { getPref, setPref } from "@/utils/settings-storages/global-settings-storage";
import { RemotePlayNavigationDialog } from "./ui/dialog/remote-play-dialog";
const LOG_TAG = 'RemotePlay';
export const enum RemotePlayConsoleState {
ON = 'On',
OFF = 'Off',
@@ -38,6 +36,7 @@ type RemotePlayConsole = {
export class RemotePlayManager {
private static instance: RemotePlayManager;
public static getInstance = () => RemotePlayManager.instance ?? (RemotePlayManager.instance = new RemotePlayManager());
private readonly LOG_TAG = 'RemotePlayManager';
private isInitialized = false;
@@ -47,6 +46,10 @@ export class RemotePlayManager {
private consoles!: Array<RemotePlayConsole>;
private regions: Array<RemotePlayRegion> = [];
private constructor() {
BxLogger.info(this.LOG_TAG, 'constructor()');
}
initialize() {
if (this.isInitialized) {
return;
@@ -56,9 +59,9 @@ export class RemotePlayManager {
this.getXhomeToken(() => {
this.getConsolesList(() => {
BxLogger.info(LOG_TAG, 'Consoles', this.consoles);
BxLogger.info(this.LOG_TAG, 'Consoles', this.consoles);
STATES.supportedRegion && HeaderSection.showRemotePlayButton();
STATES.supportedRegion && HeaderSection.getInstance().showRemotePlayButton();
BxEvent.dispatch(window, BxEvent.REMOTE_PLAY_READY);
});
});