perf: server navigation

This commit is contained in:
2026-05-18 19:38:08 +02:00
parent 0152ed9dd2
commit afb64520ed
12 changed files with 212 additions and 90 deletions

View File

@@ -80,6 +80,7 @@ export class ServersRailComponent {
menuX = signal(72);
menuY = signal(100);
contextRoom = signal<Room | null>(null);
optimisticSelectedRoomId = signal<string | null>(null);
showLeaveConfirm = signal(false);
currentUser = this.store.selectSignal(selectCurrentUser);
onlineUsers = this.store.selectSignal(selectOnlineUsers);
@@ -192,6 +193,18 @@ export class ServersRailComponent {
void this.refreshBannedLookup(rooms, currentUser ?? null);
});
effect(() => {
const optimisticRoomId = this.optimisticSelectedRoomId();
if (!optimisticRoomId) {
return;
}
if (this.currentRoom()?.id === optimisticRoomId && !this.isOnDirectMessage() && !this.isOnCall()) {
this.optimisticSelectedRoomId.set(null);
}
});
this.savedRoomJoinRequests
.pipe(
switchMap(({ room, password }) => this.requestJoinInBackground(room, password)),
@@ -214,6 +227,8 @@ export class ServersRailComponent {
createServer(): void {
const voiceServerId = this.voiceSession.getVoiceServerId();
this.optimisticSelectedRoomId.set(null);
if (voiceServerId) {
this.voiceSession.setViewingVoiceServer(false);
}
@@ -235,11 +250,13 @@ export class ServersRailComponent {
return;
}
this.optimisticSelectedRoomId.set(room.id);
this.activateSavedRoom(room);
this.savedRoomJoinRequests.next({ room });
}
openCall(callId: string): void {
this.optimisticSelectedRoomId.set(null);
void this.router.navigate(['/call', callId]);
}
@@ -335,6 +352,7 @@ export class ServersRailComponent {
);
if (isCurrentRoom) {
this.optimisticSelectedRoomId.set(null);
this.router.navigate(['/search']);
}
@@ -374,6 +392,12 @@ export class ServersRailComponent {
}
isSelectedRoom(room: Room): boolean {
const optimisticRoomId = this.optimisticSelectedRoomId();
if (optimisticRoomId) {
return optimisticRoomId === room.id;
}
if (this.isOnDirectMessage() || this.isOnCall()) {
return false;
}
@@ -492,6 +516,7 @@ export class ServersRailComponent {
if (errorCode === 'BANNED') {
this.closePasswordDialog();
this.optimisticSelectedRoomId.set(null);
this.bannedRoomLookup.update((lookup) => ({
...lookup,
[room.id]: true