Resync Mutes and Boots on reconnect to server

master
Noah 2023-12-21 14:11:37 -08:00
parent 139f9ece70
commit aa162a5b7a
1 changed files with 35 additions and 12 deletions

View File

@ -936,6 +936,13 @@ export default {
return; return;
} }
// DEBUGGING: reconnect to the server
if (this.message.toLowerCase().indexOf("/reconnect") === 0) {
this.resetChatClient();
this.message = "";
return;
}
// console.debug("Send message: %s", this.message); // console.debug("Send message: %s", this.message);
this.client.send({ this.client.send({
action: "message", action: "message",
@ -1171,15 +1178,14 @@ export default {
bulkMuteUsers() { bulkMuteUsers() {
// On page load, if the website sent you a CachedBlocklist, mute all // On page load, if the website sent you a CachedBlocklist, mute all
// of these users in bulk when the server connects. // of these users in bulk when the server connects.
// this.ChatClient("BulkMuteUsers: sending our blocklist " + this.config.CachedBlocklist);
if (this.config.CachedBlocklist.length === 0) {
return; // nothing to do
}
// If we have a blocklist from the main website, sync it to the server now.
let mapBlockedUsers = {}; // usernames on our website blocklist
if (this.config.CachedBlocklist.length > 0) {
// Set the client side mute. // Set the client side mute.
let blocklist = this.config.CachedBlocklist; let blocklist = this.config.CachedBlocklist;
for (let username of blocklist) { for (let username of blocklist) {
mapBlockedUsers[username] = true;
this.muted[username] = true; this.muted[username] = true;
} }
@ -1188,6 +1194,23 @@ export default {
action: "blocklist", action: "blocklist",
usernames: blocklist, usernames: blocklist,
}); });
}
// While we're here, also re-sync our Boot list. e.g.: we were on webcam and we
// booted someone off, then we got temporarily disconnected. The server has forgotten who
// we booted and that person could then see our cam again.
for (let username of Object.keys(this.WebRTC.booted)) {
// Boot them again.
this.sendBoot(username);
}
// Apply any temporary mutes that we had before the reconnect. Note: these are distinct
// from blocks - blocks will make people invisible both ways to each other, mutes only
// suppress messages but their Who List presence is maintained to each other.
for (let username of Object.keys(this.muted)) {
if (mapBlockedUsers[username]) continue;
this.sendMute(username, true);
}
}, },
// Send a video request to access a user's camera. // Send a video request to access a user's camera.