feat(chat): implement room synchronization for adult-only mode in MultiChatDialog.vue

- Added logic to handle room synchronization when entering a chat in adult-only mode.
- Introduced a flag to manage ongoing room sync requests, improving user experience during room transitions.
This commit is contained in:
Torsten Schulz (local)
2026-03-27 14:37:49 +01:00
parent 674c4d0b69
commit 3b823420e6

View File

@@ -363,6 +363,7 @@ export default {
heartbeatIntervalMs: 30000, // 30 seconds
connectAttemptTimeout: null,
joinFallbackTimer: null,
roomSyncInFlight: false,
// Faster handshake watchdog separate from reconnect interval
handshakeWatchdogMs: 2500,
// Rotate to next candidate if a connection never reaches 'open'
@@ -1176,9 +1177,25 @@ export default {
this.setStatus('connected');
if (this.connectAttemptTimeout) { clearTimeout(this.connectAttemptTimeout); this.connectAttemptTimeout = null; }
if (this.joinFallbackTimer) { clearTimeout(this.joinFallbackTimer); this.joinFallbackTimer = null; }
const actualRoom = msg.to || msg.room || msg.roomName || '';
const desiredRoom = this.resolveInitialRoomName();
if (
this.adultOnlyMode
&& desiredRoom
&& actualRoom
&& desiredRoom !== actualRoom
&& !this.roomSyncInFlight
) {
this.roomSyncInFlight = true;
this.sendWithToken({ type: 'join', room: desiredRoom, password: this.getRoomPassword(desiredRoom) });
window.setTimeout(() => {
this.roomSyncInFlight = false;
}, 1000);
return;
}
// Eigene Beitrittsmeldung einmalig mit Raumname anzeigen
if (!this.announcedRoomEnter) {
const room = msg.to || msg.room || msg.roomName || this.getSelectedRoomName();
const room = actualRoom || this.getSelectedRoomName();
if (room) {
const text = this.$t('chat.multichat.system.room_entered', { room });
this.messages.push({ id: msg.id || Date.now(), user: 'System', text });