Preact: Minor autoreconnect fixes (#2444)

This commit is contained in:
pyuk-bot 2025-05-27 05:17:08 -05:00 committed by GitHub
parent 482bee7d2a
commit e7c36480ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -143,7 +143,8 @@ export class PSConnection {
socket.onerror = (ev: Event) => {
PS.connected = false;
PS.isOffline = true;
PS.alert(`Connection error: ${ev as any}`);
// no useful info to print from the event
PS.alert(`Connection error`);
this.retryConnection();
PS.update();
};

View File

@ -295,8 +295,14 @@ class PSPrefs extends PSStreamModel<string | null> {
for (let title of rooms.split(",")) {
PS.addRoom({ id: toID(title) as string as RoomID, title, connected: true }, true);
};
const cmd = `/autojoin ${rooms}`;
if (PS.connection?.queue.includes(cmd)) {
// don't jam up the queue with autojoin requests
// sending autojoin again after a prior autojoin successfully resolves likely returns an error from the server
return;
}
// send even if `rooms` is empty, for server autojoins
PS.send(`/autojoin ${rooms}`);
PS.send(cmd);
}
}
}