From a117bad342b6361d6d1ace50ba7093c3400419ef Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 4 Mar 2026 23:28:54 +0100 Subject: [PATCH] Enhance room creation tracking in MultiChatDialog: Implement logic to confirm room creation success, manage pending room creation attempts, and clear tracking on dialog close. Update i18n files with new localized messages for room creation status. --- .../src/dialogues/chat/MultiChatDialog.vue | 59 +++++++++++++++++++ frontend/src/i18n/locales/de/chat.json | 4 +- frontend/src/i18n/locales/en/chat.json | 4 +- frontend/src/i18n/locales/es/chat.json | 4 +- 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/frontend/src/dialogues/chat/MultiChatDialog.vue b/frontend/src/dialogues/chat/MultiChatDialog.vue index 3de2e1d..6521d1b 100644 --- a/frontend/src/dialogues/chat/MultiChatDialog.vue +++ b/frontend/src/dialogues/chat/MultiChatDialog.vue @@ -267,6 +267,10 @@ export default { beforeUnmount() { // Safety: ensure connection is shut down on page/navigation leave this.opened = false; + if (this.pendingRoomCreateTimer) { + clearTimeout(this.pendingRoomCreateTimer); + this.pendingRoomCreateTimer = null; + } this.disconnectChatSocket(); try { window.removeEventListener('online', this.onOnline); } catch (_) { } try { document.removeEventListener('click', this.onGlobalClick); } catch (_) { } @@ -314,6 +318,9 @@ export default { roomCreateRights: [], roomCreateTypes: [], ownRooms: [], + pendingRoomCreateName: '', + pendingRoomCreateAttempts: 0, + pendingRoomCreateTimer: null, // Palette state paletteWidth: 420, paletteHeight: 220, @@ -387,6 +394,52 @@ export default { resetRoomCreateForm() { this.roomCreateForm = this.getDefaultRoomCreateForm(); }, + clearPendingRoomCreateTracking() { + if (this.pendingRoomCreateTimer) { + clearTimeout(this.pendingRoomCreateTimer); + this.pendingRoomCreateTimer = null; + } + this.pendingRoomCreateName = ''; + this.pendingRoomCreateAttempts = 0; + }, + roomNamesEqual(a, b) { + return (a || '').trim().toLowerCase() === (b || '').trim().toLowerCase(); + }, + tryConfirmRoomCreateSuccess() { + if (!this.pendingRoomCreateName) return false; + const created = this.ownRooms.find((r) => this.roomNamesEqual(r.title, this.pendingRoomCreateName)); + if (!created) return false; + this.messages.push({ + id: Date.now(), + user: 'System', + text: this.$t('chat.multichat.createRoom.messages.created', { room: created.title || this.pendingRoomCreateName }) + }); + this.clearPendingRoomCreateTracking(); + return true; + }, + scheduleRoomCreateConfirmationCheck() { + if (!this.pendingRoomCreateName) return; + if (this.pendingRoomCreateAttempts >= 6) { + this.messages.push({ + id: Date.now(), + user: 'System', + text: this.$t('chat.multichat.createRoom.messages.createNotConfirmed', { room: this.pendingRoomCreateName }) + }); + this.clearPendingRoomCreateTracking(); + return; + } + if (this.pendingRoomCreateTimer) { + clearTimeout(this.pendingRoomCreateTimer); + this.pendingRoomCreateTimer = null; + } + this.pendingRoomCreateTimer = setTimeout(async () => { + this.pendingRoomCreateAttempts += 1; + await this.loadOwnRooms(); + if (!this.tryConfirmRoomCreateSuccess()) { + this.scheduleRoomCreateConfirmationCheck(); + } + }, 1200); + }, buildRoomCreateCommandPreview() { return this.buildRoomCreateCommand(); }, @@ -428,6 +481,7 @@ export default { try { const rooms = await fetchOwnRooms(); this.ownRooms = Array.isArray(rooms) ? rooms : []; + this.tryConfirmRoomCreateSuccess(); } catch (e) { console.error('Failed loading own rooms', e); this.ownRooms = []; @@ -529,7 +583,11 @@ export default { if (this.debug) console.log('[Chat WS >>]', payload); this.sendWithToken(payload); this.messages.push({ id: Date.now(), user: 'System', text: this.$t('chat.multichat.createRoom.messages.sent', { command }) }); + this.clearPendingRoomCreateTracking(); + this.pendingRoomCreateName = (this.roomCreateForm.roomName || '').trim(); + this.pendingRoomCreateAttempts = 0; this.requestRoomRefreshAfterCreate(); + this.scheduleRoomCreateConfirmationCheck(); }, selectTargetUser(name) { if (this.selectedTargetUser === name) { @@ -567,6 +625,7 @@ export default { onDialogClose() { // Mark as closed first so any async close events won't schedule reconnect this.opened = false; + this.clearPendingRoomCreateTracking(); console.log('[Chat WS] dialog close — closing websocket'); this.disconnectChatSocket(); // Remove network event listeners diff --git a/frontend/src/i18n/locales/de/chat.json b/frontend/src/i18n/locales/de/chat.json index 01ddb93..c473b41 100644 --- a/frontend/src/i18n/locales/de/chat.json +++ b/frontend/src/i18n/locales/de/chat.json @@ -85,7 +85,9 @@ "noConnection": "Keine Verbindung zum Chat-Server.", "invalidForm": "Bitte Eingaben im Raum-Formular korrigieren.", "roomNameMissing": "Bitte einen Raumnamen angeben.", - "sent": "Raum-Erstellung gesendet: {command}" + "sent": "Raum-Erstellung gesendet: {command}", + "created": "Raum \"{room}\" wurde erfolgreich erstellt.", + "createNotConfirmed": "Raum \"{room}\" wurde noch nicht bestätigt. Bitte Raumliste prüfen." }, "ownedRooms": { "title": "Meine erstellten Räume", diff --git a/frontend/src/i18n/locales/en/chat.json b/frontend/src/i18n/locales/en/chat.json index 8fbab1c..af063b4 100644 --- a/frontend/src/i18n/locales/en/chat.json +++ b/frontend/src/i18n/locales/en/chat.json @@ -85,7 +85,9 @@ "noConnection": "No connection to chat server.", "invalidForm": "Please correct the room form inputs.", "roomNameMissing": "Please enter a room name.", - "sent": "Room creation sent: {command}" + "sent": "Room creation sent: {command}", + "created": "Room \"{room}\" was created successfully.", + "createNotConfirmed": "Room \"{room}\" is not confirmed yet. Please check room list." }, "ownedRooms": { "title": "My created rooms", diff --git a/frontend/src/i18n/locales/es/chat.json b/frontend/src/i18n/locales/es/chat.json index 057b322..dc0e951 100644 --- a/frontend/src/i18n/locales/es/chat.json +++ b/frontend/src/i18n/locales/es/chat.json @@ -84,7 +84,9 @@ "noConnection": "Sin conexión con el servidor de chat.", "invalidForm": "Corrige los datos del formulario de sala.", "roomNameMissing": "Introduce un nombre de sala.", - "sent": "Creación de sala enviada: {command}" + "sent": "Creación de sala enviada: {command}", + "created": "La sala \"{room}\" se ha creado correctamente.", + "createNotConfirmed": "La sala \"{room}\" aún no está confirmada. Revisa la lista de salas." }, "ownedRooms": { "title": "Mis salas creadas",