mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-10 15:17:45 +02:00
Fix Server badge not updating between sessions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user