feat: signal server tag

This commit is contained in:
2026-06-05 06:16:02 +02:00
parent 6865147e8f
commit bf4e6891d1
69 changed files with 2808 additions and 1269 deletions

View File

@@ -7,12 +7,15 @@ import {
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Actions } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideUserPlus } from '@ng-icons/lucide';
import { firstValueFrom } from 'rxjs';
import { AuthenticationService } from '../../application/services/authentication.service';
import { ServerDirectoryFacade } from '../../../server-directory';
import { waitForAuthenticationOutcome } from '../../domain/logic/auth-navigation.rules';
import { UsersActions } from '../../../../store/users/users.actions';
import { User } from '../../../../shared-kernel';
@@ -41,6 +44,7 @@ export class RegisterComponent {
error = signal<string | null>(null);
private auth = inject(AuthenticationService);
private actions$ = inject(Actions);
private store = inject(Store);
private route = inject(ActivatedRoute);
private router = inject(Router);
@@ -57,10 +61,12 @@ export class RegisterComponent {
password: this.password,
displayName: this.displayName.trim(),
serverId: sid }).subscribe({
next: (resp) => {
next: async (resp) => {
if (sid)
this.serversSvc.setActiveServer(sid);
const homeSignalServerUrl = this.serversSvc.servers().find((server) => server.id === sid)?.url
?? this.serversSvc.activeServer()?.url;
const user: User = {
id: resp.id,
oderId: resp.id,
@@ -68,19 +74,27 @@ export class RegisterComponent {
displayName: resp.displayName,
status: 'online',
role: 'member',
joinedAt: Date.now()
joinedAt: Date.now(),
homeSignalServerUrl
};
this.store.dispatch(UsersActions.authenticateUser({ user }));
const returnUrl = this.route.snapshot.queryParamMap.get('returnUrl')?.trim();
if (returnUrl?.startsWith('/')) {
this.router.navigateByUrl(returnUrl);
const outcome = await firstValueFrom(waitForAuthenticationOutcome(this.actions$));
if (outcome.kind === 'failure') {
this.error.set(outcome.error);
return;
}
this.router.navigate(['/dashboard']);
const returnUrl = this.route.snapshot.queryParamMap.get('returnUrl')?.trim();
if (returnUrl?.startsWith('/')) {
await this.router.navigateByUrl(returnUrl);
return;
}
await this.router.navigate(['/dashboard']);
},
error: (err) => {
this.error.set(err?.error?.error || 'Registration failed');