Multi server connection

This commit is contained in:
2026-03-01 15:26:08 +01:00
parent d88a476f15
commit d146138fca
7 changed files with 278 additions and 86 deletions

View File

@@ -8,6 +8,7 @@ import { lucidePlus } from '@ng-icons/lucide';
import { Room } from '../../core/models';
import { selectSavedRooms, selectCurrentRoom } from '../../store/rooms/rooms.selectors';
import { VoiceSessionService } from '../../core/services/voice-session.service';
import { WebRTCService } from '../../core/services/webrtc.service';
import * as RoomsActions from '../../store/rooms/rooms.actions';
@Component({
@@ -21,6 +22,7 @@ export class ServersRailComponent {
private store = inject(Store);
private router = inject(Router);
private voiceSession = inject(VoiceSessionService);
private webrtc = inject(WebRTCService);
savedRooms = this.store.selectSignal(selectSavedRooms);
currentRoom = this.store.selectSignal(selectCurrentRoom);
@@ -52,8 +54,6 @@ export class ServersRailComponent {
joinSavedRoom(room: Room): void {
// Require auth: if no current user, go to login
const current = this.currentRoom();
// currentRoom presence does not indicate auth; check localStorage for currentUserId
const currentUserId = localStorage.getItem('metoyou_currentUserId');
if (!currentUserId) {
this.router.navigate(['/login']);
@@ -64,21 +64,28 @@ export class ServersRailComponent {
const voiceServerId = this.voiceSession.getVoiceServerId();
if (voiceServerId && voiceServerId !== room.id) {
// User is switching to a different server while connected to voice
// Update voice session to show floating controls
// Update voice session to show floating controls (voice stays connected)
this.voiceSession.setViewingVoiceServer(false);
} else if (voiceServerId === room.id) {
// Navigating back to the voice-connected server
this.voiceSession.setViewingVoiceServer(true);
}
this.store.dispatch(RoomsActions.joinRoom({
roomId: room.id,
serverInfo: {
name: room.name,
description: room.description,
hostName: room.hostId || 'Unknown',
},
}));
// If we've already joined this server, just switch the view
// (no user_joined broadcast, no leave from other servers)
if (this.webrtc.hasJoinedServer(room.id)) {
this.store.dispatch(RoomsActions.viewServer({ room }));
} else {
// First time joining this server
this.store.dispatch(RoomsActions.joinRoom({
roomId: room.id,
serverInfo: {
name: room.name,
description: room.description,
hostName: room.hostId || 'Unknown',
},
}));
}
}
openContextMenu(evt: MouseEvent, room: Room): void {