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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user