feat: Admin Area Players Management 1.00
This commit is contained in:
@@ -17,6 +17,8 @@ import { EventStatusStore } from '../../core/services/event-status.store';
|
||||
import { AuthenticatedEventSourceService } from '../../core/services/authenticated-event-source.service';
|
||||
import { UserStore } from '../../core/services/user.store';
|
||||
import { ChallengesStore } from '../challenges/challenges.store';
|
||||
import { NotificationService } from '../../core/services/notification.service';
|
||||
import { CrossTabRoleChangeMessage } from '../../core/services/auth-session-events.pure';
|
||||
import { ShellHeaderComponent } from '../shell/header/shell-header.component';
|
||||
import {
|
||||
ChangePasswordModalComponent,
|
||||
@@ -95,6 +97,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
private readonly challengesStore = inject(ChallengesStore);
|
||||
private readonly router = inject(Router);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly notifications = inject(NotificationService);
|
||||
|
||||
readonly userMenuOpen = signal(false);
|
||||
readonly changePasswordOpen = signal(false);
|
||||
@@ -138,6 +141,9 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
this.peerInvalidationUnsubscribe = this.auth.onPeerInvalidation((reason) =>
|
||||
this.handleSessionInvalidated(reason),
|
||||
);
|
||||
this.peerRoleChangeUnsubscribe = this.auth.onPeerRoleChange((msg) =>
|
||||
this.handlePeerRoleChange(msg),
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
@@ -146,6 +152,10 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
this.peerInvalidationUnsubscribe();
|
||||
this.peerInvalidationUnsubscribe = null;
|
||||
}
|
||||
if (this.peerRoleChangeUnsubscribe) {
|
||||
this.peerRoleChangeUnsubscribe();
|
||||
this.peerRoleChangeUnsubscribe = null;
|
||||
}
|
||||
}
|
||||
|
||||
goHome(): void {
|
||||
@@ -207,6 +217,7 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private peerInvalidationUnsubscribe: (() => void) | null = null;
|
||||
private peerRoleChangeUnsubscribe: (() => void) | null = null;
|
||||
private navigatingToLogin = false;
|
||||
|
||||
private async handleSessionInvalidated(
|
||||
@@ -225,4 +236,14 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
this.navigatingToLogin = false;
|
||||
}
|
||||
}
|
||||
|
||||
private handlePeerRoleChange(msg: CrossTabRoleChangeMessage): void {
|
||||
const me = this.auth.currentUser();
|
||||
if (!me || me.id !== msg.userId) return;
|
||||
this.userStore.setRole(msg.newRole);
|
||||
if (!this.router.url.startsWith('/admin/')) return;
|
||||
this.notifications.info(
|
||||
`Your role was changed to "${msg.newRole}" by another admin. You may need to refresh or log in again to continue.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user