mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 07:37:19 +02:00
Fix Server badge not updating between sessions
This commit is contained in:
parent
8664c1a60f
commit
87447df7fd
24
dist/better-xcloud.lite.user.js
vendored
24
dist/better-xcloud.lite.user.js
vendored
@ -1867,7 +1867,7 @@ class StreamStats {
|
|||||||
if (this.isGlancing()) this.$container && (this.$container.dataset.display = "fixed");
|
if (this.isGlancing()) this.$container && (this.$container.dataset.display = "fixed");
|
||||||
else this.isHidden() ? await this.start() : await this.stop();
|
else this.isHidden() ? await this.start() : await this.stop();
|
||||||
}
|
}
|
||||||
onStoppedPlaying() {
|
destroy() {
|
||||||
this.stop(), this.quickGlanceStop(), this.hideSettingsUi();
|
this.stop(), this.quickGlanceStop(), this.hideSettingsUi();
|
||||||
}
|
}
|
||||||
isHidden = () => this.$container.classList.contains("bx-gone");
|
isHidden = () => this.$container.classList.contains("bx-gone");
|
||||||
@ -1894,7 +1894,7 @@ class StreamStats {
|
|||||||
}
|
}
|
||||||
async update(forceUpdate = !1) {
|
async update(forceUpdate = !1) {
|
||||||
if (!forceUpdate && this.isHidden() || !STATES.currentStream.peerConnection) {
|
if (!forceUpdate && this.isHidden() || !STATES.currentStream.peerConnection) {
|
||||||
this.onStoppedPlaying();
|
this.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let PREF_STATS_CONDITIONAL_FORMATTING = getPref("stats_conditional_formatting"), grade = "", statsCollector = StreamStatsCollector.getInstance();
|
let PREF_STATS_CONDITIONAL_FORMATTING = getPref("stats_conditional_formatting"), grade = "", statsCollector = StreamStatsCollector.getInstance();
|
||||||
@ -4526,8 +4526,7 @@ class StreamBadges {
|
|||||||
REFRESH_INTERVAL = 3000;
|
REFRESH_INTERVAL = 3000;
|
||||||
setRegion(region) {
|
setRegion(region) {
|
||||||
this.serverInfo.server = {
|
this.serverInfo.server = {
|
||||||
region,
|
region
|
||||||
ipv6: !1
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
renderBadge(name, value) {
|
renderBadge(name, value) {
|
||||||
@ -4564,6 +4563,9 @@ class StreamBadges {
|
|||||||
stop() {
|
stop() {
|
||||||
this.intervalId && clearInterval(this.intervalId), this.intervalId = null;
|
this.intervalId && clearInterval(this.intervalId), this.intervalId = null;
|
||||||
}
|
}
|
||||||
|
destroy() {
|
||||||
|
this.serverInfo = {}, delete this.$container;
|
||||||
|
}
|
||||||
async render() {
|
async render() {
|
||||||
if (this.$container) return this.start(), this.$container;
|
if (this.$container) return this.start(), this.$container;
|
||||||
await this.getServerStats();
|
await this.getServerStats();
|
||||||
@ -4574,7 +4576,7 @@ class StreamBadges {
|
|||||||
["battery", batteryLevel],
|
["battery", batteryLevel],
|
||||||
["download", humanFileSize(0)],
|
["download", humanFileSize(0)],
|
||||||
["upload", humanFileSize(0)],
|
["upload", humanFileSize(0)],
|
||||||
this.serverInfo.server ? this.badges.server.$element : ["server", "?"],
|
this.badges.server.$element ?? ["server", "?"],
|
||||||
this.serverInfo.video ? this.badges.video.$element : ["video", "?"],
|
this.serverInfo.video ? this.badges.video.$element : ["video", "?"],
|
||||||
this.serverInfo.audio ? this.badges.audio.$element : ["audio", "?"]
|
this.serverInfo.audio ? this.badges.audio.$element : ["audio", "?"]
|
||||||
], $container = CE("div", { class: "bx-badges" });
|
], $container = CE("div", { class: "bx-badges" });
|
||||||
@ -4627,13 +4629,9 @@ class StreamBadges {
|
|||||||
}
|
}
|
||||||
if (candidateId) {
|
if (candidateId) {
|
||||||
BxLogger.info("candidate", candidateId, allCandidates);
|
BxLogger.info("candidate", candidateId, allCandidates);
|
||||||
let server = this.serverInfo.server;
|
let text = "", isIpv6 = allCandidates[candidateId].includes(":"), server = this.serverInfo.server;
|
||||||
if (server) {
|
if (server && server.region) text += server.region;
|
||||||
server.ipv6 = allCandidates[candidateId].includes(":");
|
text += "@" + (isIpv6 ? "IPv6" : "IPv4"), this.badges.server.$element = this.renderBadge("server", text);
|
||||||
let text = "";
|
|
||||||
if (server.region) text += server.region;
|
|
||||||
text += "@" + (server.ipv6 ? "IPv6" : "IPv4"), this.badges.server.$element = this.renderBadge("server", text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static setupEvents() {
|
static setupEvents() {
|
||||||
@ -5617,7 +5615,7 @@ window.addEventListener(BxEvent.DATA_CHANNEL_CREATED, (e) => {
|
|||||||
});
|
});
|
||||||
function unload() {
|
function unload() {
|
||||||
if (!STATES.isPlaying) return;
|
if (!STATES.isPlaying) return;
|
||||||
STATES.currentStream.streamPlayer?.destroy(), STATES.isPlaying = !1, STATES.currentStream = {}, window.BX_EXPOSED.shouldShowSensorControls = !1, window.BX_EXPOSED.stopTakRendering = !1, NavigationDialogManager.getInstance().hide(), StreamStats.getInstance().onStoppedPlaying();
|
STATES.currentStream.streamPlayer?.destroy(), STATES.isPlaying = !1, STATES.currentStream = {}, window.BX_EXPOSED.shouldShowSensorControls = !1, window.BX_EXPOSED.stopTakRendering = !1, NavigationDialogManager.getInstance().hide(), StreamStats.getInstance().destroy(), StreamBadges.getInstance().destroy();
|
||||||
}
|
}
|
||||||
window.addEventListener(BxEvent.STREAM_STOPPED, unload);
|
window.addEventListener(BxEvent.STREAM_STOPPED, unload);
|
||||||
window.addEventListener("pagehide", (e) => {
|
window.addEventListener("pagehide", (e) => {
|
||||||
|
24
dist/better-xcloud.user.js
vendored
24
dist/better-xcloud.user.js
vendored
@ -1934,7 +1934,7 @@ class StreamStats {
|
|||||||
if (this.isGlancing()) this.$container && (this.$container.dataset.display = "fixed");
|
if (this.isGlancing()) this.$container && (this.$container.dataset.display = "fixed");
|
||||||
else this.isHidden() ? await this.start() : await this.stop();
|
else this.isHidden() ? await this.start() : await this.stop();
|
||||||
}
|
}
|
||||||
onStoppedPlaying() {
|
destroy() {
|
||||||
this.stop(), this.quickGlanceStop(), this.hideSettingsUi();
|
this.stop(), this.quickGlanceStop(), this.hideSettingsUi();
|
||||||
}
|
}
|
||||||
isHidden = () => this.$container.classList.contains("bx-gone");
|
isHidden = () => this.$container.classList.contains("bx-gone");
|
||||||
@ -1961,7 +1961,7 @@ class StreamStats {
|
|||||||
}
|
}
|
||||||
async update(forceUpdate = !1) {
|
async update(forceUpdate = !1) {
|
||||||
if (!forceUpdate && this.isHidden() || !STATES.currentStream.peerConnection) {
|
if (!forceUpdate && this.isHidden() || !STATES.currentStream.peerConnection) {
|
||||||
this.onStoppedPlaying();
|
this.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let PREF_STATS_CONDITIONAL_FORMATTING = getPref("stats_conditional_formatting"), grade = "", statsCollector = StreamStatsCollector.getInstance();
|
let PREF_STATS_CONDITIONAL_FORMATTING = getPref("stats_conditional_formatting"), grade = "", statsCollector = StreamStatsCollector.getInstance();
|
||||||
@ -6372,8 +6372,7 @@ class StreamBadges {
|
|||||||
REFRESH_INTERVAL = 3000;
|
REFRESH_INTERVAL = 3000;
|
||||||
setRegion(region) {
|
setRegion(region) {
|
||||||
this.serverInfo.server = {
|
this.serverInfo.server = {
|
||||||
region,
|
region
|
||||||
ipv6: !1
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
renderBadge(name, value) {
|
renderBadge(name, value) {
|
||||||
@ -6410,6 +6409,9 @@ class StreamBadges {
|
|||||||
stop() {
|
stop() {
|
||||||
this.intervalId && clearInterval(this.intervalId), this.intervalId = null;
|
this.intervalId && clearInterval(this.intervalId), this.intervalId = null;
|
||||||
}
|
}
|
||||||
|
destroy() {
|
||||||
|
this.serverInfo = {}, delete this.$container;
|
||||||
|
}
|
||||||
async render() {
|
async render() {
|
||||||
if (this.$container) return this.start(), this.$container;
|
if (this.$container) return this.start(), this.$container;
|
||||||
await this.getServerStats();
|
await this.getServerStats();
|
||||||
@ -6420,7 +6422,7 @@ class StreamBadges {
|
|||||||
["battery", batteryLevel],
|
["battery", batteryLevel],
|
||||||
["download", humanFileSize(0)],
|
["download", humanFileSize(0)],
|
||||||
["upload", humanFileSize(0)],
|
["upload", humanFileSize(0)],
|
||||||
this.serverInfo.server ? this.badges.server.$element : ["server", "?"],
|
this.badges.server.$element ?? ["server", "?"],
|
||||||
this.serverInfo.video ? this.badges.video.$element : ["video", "?"],
|
this.serverInfo.video ? this.badges.video.$element : ["video", "?"],
|
||||||
this.serverInfo.audio ? this.badges.audio.$element : ["audio", "?"]
|
this.serverInfo.audio ? this.badges.audio.$element : ["audio", "?"]
|
||||||
], $container = CE("div", { class: "bx-badges" });
|
], $container = CE("div", { class: "bx-badges" });
|
||||||
@ -6473,13 +6475,9 @@ class StreamBadges {
|
|||||||
}
|
}
|
||||||
if (candidateId) {
|
if (candidateId) {
|
||||||
BxLogger.info("candidate", candidateId, allCandidates);
|
BxLogger.info("candidate", candidateId, allCandidates);
|
||||||
let server = this.serverInfo.server;
|
let text = "", isIpv6 = allCandidates[candidateId].includes(":"), server = this.serverInfo.server;
|
||||||
if (server) {
|
if (server && server.region) text += server.region;
|
||||||
server.ipv6 = allCandidates[candidateId].includes(":");
|
text += "@" + (isIpv6 ? "IPv6" : "IPv4"), this.badges.server.$element = this.renderBadge("server", text);
|
||||||
let text = "";
|
|
||||||
if (server.region) text += server.region;
|
|
||||||
text += "@" + (server.ipv6 ? "IPv6" : "IPv4"), this.badges.server.$element = this.renderBadge("server", text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static setupEvents() {}
|
static setupEvents() {}
|
||||||
@ -7845,7 +7843,7 @@ window.addEventListener(BxEvent.DATA_CHANNEL_CREATED, (e) => {
|
|||||||
});
|
});
|
||||||
function unload() {
|
function unload() {
|
||||||
if (!STATES.isPlaying) return;
|
if (!STATES.isPlaying) return;
|
||||||
EmulatedMkbHandler.getInstance().destroy(), NativeMkbHandler.getInstance().destroy(), STATES.currentStream.streamPlayer?.destroy(), STATES.isPlaying = !1, STATES.currentStream = {}, window.BX_EXPOSED.shouldShowSensorControls = !1, window.BX_EXPOSED.stopTakRendering = !1, NavigationDialogManager.getInstance().hide(), StreamStats.getInstance().onStoppedPlaying(), MouseCursorHider.stop(), TouchController.reset(), GameBar.getInstance().disable();
|
EmulatedMkbHandler.getInstance().destroy(), NativeMkbHandler.getInstance().destroy(), STATES.currentStream.streamPlayer?.destroy(), STATES.isPlaying = !1, STATES.currentStream = {}, window.BX_EXPOSED.shouldShowSensorControls = !1, window.BX_EXPOSED.stopTakRendering = !1, NavigationDialogManager.getInstance().hide(), StreamStats.getInstance().destroy(), StreamBadges.getInstance().destroy(), MouseCursorHider.stop(), TouchController.reset(), GameBar.getInstance().disable();
|
||||||
}
|
}
|
||||||
window.addEventListener(BxEvent.STREAM_STOPPED, unload);
|
window.addEventListener(BxEvent.STREAM_STOPPED, unload);
|
||||||
window.addEventListener("pagehide", (e) => {
|
window.addEventListener("pagehide", (e) => {
|
||||||
|
@ -310,7 +310,8 @@ function unload() {
|
|||||||
window.BX_EXPOSED.stopTakRendering = false;
|
window.BX_EXPOSED.stopTakRendering = false;
|
||||||
|
|
||||||
NavigationDialogManager.getInstance().hide();
|
NavigationDialogManager.getInstance().hide();
|
||||||
StreamStats.getInstance().onStoppedPlaying();
|
StreamStats.getInstance().destroy();
|
||||||
|
StreamBadges.getInstance().destroy();
|
||||||
|
|
||||||
if (isFullVersion()) {
|
if (isFullVersion()) {
|
||||||
MouseCursorHider.stop();
|
MouseCursorHider.stop();
|
||||||
|
@ -19,7 +19,6 @@ type StreamBadgeInfo = {
|
|||||||
|
|
||||||
type StreamServerInfo = {
|
type StreamServerInfo = {
|
||||||
server?: {
|
server?: {
|
||||||
ipv6: boolean,
|
|
||||||
region?: string,
|
region?: string,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -100,7 +99,6 @@ export class StreamBadges {
|
|||||||
setRegion(region: string) {
|
setRegion(region: string) {
|
||||||
this.serverInfo.server = {
|
this.serverInfo.server = {
|
||||||
region: region,
|
region: region,
|
||||||
ipv6: false,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +184,11 @@ export class StreamBadges {
|
|||||||
this.intervalId = null;
|
this.intervalId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
this.serverInfo = {};
|
||||||
|
delete this.$container;
|
||||||
|
}
|
||||||
|
|
||||||
async render() {
|
async render() {
|
||||||
if (this.$container) {
|
if (this.$container) {
|
||||||
this.start();
|
this.start();
|
||||||
@ -205,7 +208,7 @@ export class StreamBadges {
|
|||||||
[StreamBadge.BATTERY, batteryLevel],
|
[StreamBadge.BATTERY, batteryLevel],
|
||||||
[StreamBadge.DOWNLOAD, humanFileSize(0)],
|
[StreamBadge.DOWNLOAD, humanFileSize(0)],
|
||||||
[StreamBadge.UPLOAD, humanFileSize(0)],
|
[StreamBadge.UPLOAD, humanFileSize(0)],
|
||||||
this.serverInfo.server ? this.badges.server.$element : [StreamBadge.SERVER, '?'],
|
this.badges.server.$element ?? [StreamBadge.SERVER, '?'],
|
||||||
this.serverInfo.video ? this.badges.video.$element : [StreamBadge.VIDEO, '?'],
|
this.serverInfo.video ? this.badges.video.$element : [StreamBadge.VIDEO, '?'],
|
||||||
this.serverInfo.audio ? this.badges.audio.$element : [StreamBadge.AUDIO, '?'],
|
this.serverInfo.audio ? this.badges.audio.$element : [StreamBadge.AUDIO, '?'],
|
||||||
];
|
];
|
||||||
@ -330,18 +333,16 @@ export class StreamBadges {
|
|||||||
BxLogger.info('candidate', candidateId, allCandidates);
|
BxLogger.info('candidate', candidateId, allCandidates);
|
||||||
|
|
||||||
// Server + Region
|
// Server + Region
|
||||||
|
let text = '';
|
||||||
|
const isIpv6 = allCandidates[candidateId].includes(':');
|
||||||
|
|
||||||
const server = this.serverInfo.server;
|
const server = this.serverInfo.server;
|
||||||
if (server) {
|
if (server && server.region) {
|
||||||
server.ipv6 = allCandidates[candidateId].includes(':');
|
text += server.region;
|
||||||
|
|
||||||
let text = '';
|
|
||||||
if (server.region) {
|
|
||||||
text += server.region;
|
|
||||||
}
|
|
||||||
|
|
||||||
text += '@' + (server.ipv6 ? 'IPv6' : 'IPv4');
|
|
||||||
this.badges.server.$element = this.renderBadge(StreamBadge.SERVER, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text += '@' + (isIpv6 ? 'IPv6' : 'IPv4');
|
||||||
|
this.badges.server.$element = this.renderBadge(StreamBadge.SERVER, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ export class StreamStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onStoppedPlaying() {
|
destroy() {
|
||||||
this.stop();
|
this.stop();
|
||||||
this.quickGlanceStop();
|
this.quickGlanceStop();
|
||||||
this.hideSettingsUi();
|
this.hideSettingsUi();
|
||||||
@ -156,7 +156,7 @@ export class StreamStats {
|
|||||||
|
|
||||||
private async update(forceUpdate=false) {
|
private async update(forceUpdate=false) {
|
||||||
if ((!forceUpdate && this.isHidden()) || !STATES.currentStream.peerConnection) {
|
if ((!forceUpdate && this.isHidden()) || !STATES.currentStream.peerConnection) {
|
||||||
this.onStoppedPlaying();
|
this.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user