mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-04 22:57: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");
|
||||
else this.isHidden() ? await this.start() : await this.stop();
|
||||
}
|
||||
onStoppedPlaying() {
|
||||
destroy() {
|
||||
this.stop(), this.quickGlanceStop(), this.hideSettingsUi();
|
||||
}
|
||||
isHidden = () => this.$container.classList.contains("bx-gone");
|
||||
@ -1894,7 +1894,7 @@ class StreamStats {
|
||||
}
|
||||
async update(forceUpdate = !1) {
|
||||
if (!forceUpdate && this.isHidden() || !STATES.currentStream.peerConnection) {
|
||||
this.onStoppedPlaying();
|
||||
this.destroy();
|
||||
return;
|
||||
}
|
||||
let PREF_STATS_CONDITIONAL_FORMATTING = getPref("stats_conditional_formatting"), grade = "", statsCollector = StreamStatsCollector.getInstance();
|
||||
@ -4526,8 +4526,7 @@ class StreamBadges {
|
||||
REFRESH_INTERVAL = 3000;
|
||||
setRegion(region) {
|
||||
this.serverInfo.server = {
|
||||
region,
|
||||
ipv6: !1
|
||||
region
|
||||
};
|
||||
}
|
||||
renderBadge(name, value) {
|
||||
@ -4564,6 +4563,9 @@ class StreamBadges {
|
||||
stop() {
|
||||
this.intervalId && clearInterval(this.intervalId), this.intervalId = null;
|
||||
}
|
||||
destroy() {
|
||||
this.serverInfo = {}, delete this.$container;
|
||||
}
|
||||
async render() {
|
||||
if (this.$container) return this.start(), this.$container;
|
||||
await this.getServerStats();
|
||||
@ -4574,7 +4576,7 @@ class StreamBadges {
|
||||
["battery", batteryLevel],
|
||||
["download", 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.audio ? this.badges.audio.$element : ["audio", "?"]
|
||||
], $container = CE("div", { class: "bx-badges" });
|
||||
@ -4627,13 +4629,9 @@ class StreamBadges {
|
||||
}
|
||||
if (candidateId) {
|
||||
BxLogger.info("candidate", candidateId, allCandidates);
|
||||
let server = this.serverInfo.server;
|
||||
if (server) {
|
||||
server.ipv6 = allCandidates[candidateId].includes(":");
|
||||
let text = "";
|
||||
if (server.region) text += server.region;
|
||||
text += "@" + (server.ipv6 ? "IPv6" : "IPv4"), this.badges.server.$element = this.renderBadge("server", text);
|
||||
}
|
||||
let text = "", isIpv6 = allCandidates[candidateId].includes(":"), server = this.serverInfo.server;
|
||||
if (server && server.region) text += server.region;
|
||||
text += "@" + (isIpv6 ? "IPv6" : "IPv4"), this.badges.server.$element = this.renderBadge("server", text);
|
||||
}
|
||||
}
|
||||
static setupEvents() {
|
||||
@ -5617,7 +5615,7 @@ window.addEventListener(BxEvent.DATA_CHANNEL_CREATED, (e) => {
|
||||
});
|
||||
function unload() {
|
||||
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("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");
|
||||
else this.isHidden() ? await this.start() : await this.stop();
|
||||
}
|
||||
onStoppedPlaying() {
|
||||
destroy() {
|
||||
this.stop(), this.quickGlanceStop(), this.hideSettingsUi();
|
||||
}
|
||||
isHidden = () => this.$container.classList.contains("bx-gone");
|
||||
@ -1961,7 +1961,7 @@ class StreamStats {
|
||||
}
|
||||
async update(forceUpdate = !1) {
|
||||
if (!forceUpdate && this.isHidden() || !STATES.currentStream.peerConnection) {
|
||||
this.onStoppedPlaying();
|
||||
this.destroy();
|
||||
return;
|
||||
}
|
||||
let PREF_STATS_CONDITIONAL_FORMATTING = getPref("stats_conditional_formatting"), grade = "", statsCollector = StreamStatsCollector.getInstance();
|
||||
@ -6372,8 +6372,7 @@ class StreamBadges {
|
||||
REFRESH_INTERVAL = 3000;
|
||||
setRegion(region) {
|
||||
this.serverInfo.server = {
|
||||
region,
|
||||
ipv6: !1
|
||||
region
|
||||
};
|
||||
}
|
||||
renderBadge(name, value) {
|
||||
@ -6410,6 +6409,9 @@ class StreamBadges {
|
||||
stop() {
|
||||
this.intervalId && clearInterval(this.intervalId), this.intervalId = null;
|
||||
}
|
||||
destroy() {
|
||||
this.serverInfo = {}, delete this.$container;
|
||||
}
|
||||
async render() {
|
||||
if (this.$container) return this.start(), this.$container;
|
||||
await this.getServerStats();
|
||||
@ -6420,7 +6422,7 @@ class StreamBadges {
|
||||
["battery", batteryLevel],
|
||||
["download", 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.audio ? this.badges.audio.$element : ["audio", "?"]
|
||||
], $container = CE("div", { class: "bx-badges" });
|
||||
@ -6473,13 +6475,9 @@ class StreamBadges {
|
||||
}
|
||||
if (candidateId) {
|
||||
BxLogger.info("candidate", candidateId, allCandidates);
|
||||
let server = this.serverInfo.server;
|
||||
if (server) {
|
||||
server.ipv6 = allCandidates[candidateId].includes(":");
|
||||
let text = "";
|
||||
if (server.region) text += server.region;
|
||||
text += "@" + (server.ipv6 ? "IPv6" : "IPv4"), this.badges.server.$element = this.renderBadge("server", text);
|
||||
}
|
||||
let text = "", isIpv6 = allCandidates[candidateId].includes(":"), server = this.serverInfo.server;
|
||||
if (server && server.region) text += server.region;
|
||||
text += "@" + (isIpv6 ? "IPv6" : "IPv4"), this.badges.server.$element = this.renderBadge("server", text);
|
||||
}
|
||||
}
|
||||
static setupEvents() {}
|
||||
@ -7845,7 +7843,7 @@ window.addEventListener(BxEvent.DATA_CHANNEL_CREATED, (e) => {
|
||||
});
|
||||
function unload() {
|
||||
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("pagehide", (e) => {
|
||||
|
@ -310,7 +310,8 @@ function unload() {
|
||||
window.BX_EXPOSED.stopTakRendering = false;
|
||||
|
||||
NavigationDialogManager.getInstance().hide();
|
||||
StreamStats.getInstance().onStoppedPlaying();
|
||||
StreamStats.getInstance().destroy();
|
||||
StreamBadges.getInstance().destroy();
|
||||
|
||||
if (isFullVersion()) {
|
||||
MouseCursorHider.stop();
|
||||
|
@ -19,7 +19,6 @@ type StreamBadgeInfo = {
|
||||
|
||||
type StreamServerInfo = {
|
||||
server?: {
|
||||
ipv6: boolean,
|
||||
region?: string,
|
||||
},
|
||||
|
||||
@ -100,7 +99,6 @@ export class StreamBadges {
|
||||
setRegion(region: string) {
|
||||
this.serverInfo.server = {
|
||||
region: region,
|
||||
ipv6: false,
|
||||
};
|
||||
}
|
||||
|
||||
@ -186,6 +184,11 @@ export class StreamBadges {
|
||||
this.intervalId = null;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.serverInfo = {};
|
||||
delete this.$container;
|
||||
}
|
||||
|
||||
async render() {
|
||||
if (this.$container) {
|
||||
this.start();
|
||||
@ -205,7 +208,7 @@ export class StreamBadges {
|
||||
[StreamBadge.BATTERY, batteryLevel],
|
||||
[StreamBadge.DOWNLOAD, 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.audio ? this.badges.audio.$element : [StreamBadge.AUDIO, '?'],
|
||||
];
|
||||
@ -330,18 +333,16 @@ export class StreamBadges {
|
||||
BxLogger.info('candidate', candidateId, allCandidates);
|
||||
|
||||
// Server + Region
|
||||
let text = '';
|
||||
const isIpv6 = allCandidates[candidateId].includes(':');
|
||||
|
||||
const server = this.serverInfo.server;
|
||||
if (server) {
|
||||
server.ipv6 = allCandidates[candidateId].includes(':');
|
||||
|
||||
let text = '';
|
||||
if (server.region) {
|
||||
text += server.region;
|
||||
}
|
||||
|
||||
text += '@' + (server.ipv6 ? 'IPv6' : 'IPv4');
|
||||
this.badges.server.$element = this.renderBadge(StreamBadge.SERVER, text);
|
||||
if (server && server.region) {
|
||||
text += server.region;
|
||||
}
|
||||
|
||||
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.quickGlanceStop();
|
||||
this.hideSettingsUi();
|
||||
@ -156,7 +156,7 @@ export class StreamStats {
|
||||
|
||||
private async update(forceUpdate=false) {
|
||||
if ((!forceUpdate && this.isHidden()) || !STATES.currentStream.peerConnection) {
|
||||
this.onStoppedPlaying();
|
||||
this.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user