Simple Managment webapp [LLM]
This commit is contained in:
@@ -16,6 +16,7 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
|
||||
import { ApiService } from '../../../core/services/api.service';
|
||||
import { AuthService } from '../../../core/services/auth.service';
|
||||
import { NotificationService } from '../../../core/services/notification.service';
|
||||
import { UserCacheService, ResolvedUser } from '../../../core/services/user-cache.service';
|
||||
import { Subscription, SubscriptionFilter } from '../../../core/models';
|
||||
import { RelativeTimePipe } from '../../../shared/pipes/relative-time.pipe';
|
||||
|
||||
@@ -48,8 +49,10 @@ export class SubscriptionListComponent implements OnInit {
|
||||
private apiService = inject(ApiService);
|
||||
private authService = inject(AuthService);
|
||||
private notification = inject(NotificationService);
|
||||
private userCacheService = inject(UserCacheService);
|
||||
|
||||
subscriptions = signal<Subscription[]>([]);
|
||||
userNames = signal<Map<string, ResolvedUser>>(new Map());
|
||||
loading = signal(false);
|
||||
direction: TabDirection = 'both';
|
||||
|
||||
@@ -78,6 +81,7 @@ export class SubscriptionListComponent implements OnInit {
|
||||
next: (response) => {
|
||||
this.subscriptions.set(response.subscriptions);
|
||||
this.loading.set(false);
|
||||
this.resolveUserNames(response.subscriptions);
|
||||
},
|
||||
error: () => {
|
||||
this.loading.set(false);
|
||||
@@ -85,6 +89,24 @@ export class SubscriptionListComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
private resolveUserNames(subscriptions: Subscription[]): void {
|
||||
const userIds = new Set<string>();
|
||||
for (const sub of subscriptions) {
|
||||
userIds.add(sub.subscriber_user_id);
|
||||
userIds.add(sub.channel_owner_user_id);
|
||||
}
|
||||
for (const id of userIds) {
|
||||
this.userCacheService.resolveUser(id).subscribe(resolved => {
|
||||
this.userNames.update(map => new Map(map).set(id, resolved));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getUserDisplayName(userId: string): string {
|
||||
const resolved = this.userNames().get(userId);
|
||||
return resolved?.displayName || userId;
|
||||
}
|
||||
|
||||
onTabChange(index: number): void {
|
||||
const directions: TabDirection[] = ['both', 'outgoing', 'incoming'];
|
||||
this.direction = directions[index];
|
||||
|
||||
Reference in New Issue
Block a user