UI improvements
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable, of, catchError, map, shareReplay } from 'rxjs';
|
||||
import { ApiService } from './api.service';
|
||||
import { ClientPreview, UserPreview } from '../models';
|
||||
|
||||
export interface ResolvedClient {
|
||||
clientId: string;
|
||||
@@ -17,18 +18,14 @@ export interface ResolvedClient {
|
||||
export class ClientCacheService {
|
||||
private apiService = inject(ApiService);
|
||||
|
||||
private cache = new Map<string, Observable<ResolvedClient | null>>();
|
||||
private cache = new Map<string, Observable<{client: ClientPreview, user: UserPreview} | null>>();
|
||||
|
||||
resolveClient(clientId: string): Observable<ResolvedClient | null> {
|
||||
resolveClient(clientId: string): Observable<{client: ClientPreview, user: UserPreview} | null> {
|
||||
if (!this.cache.has(clientId)) {
|
||||
const request$ = this.apiService.getClientPreview(clientId).pipe(
|
||||
map(response => ({
|
||||
clientId: response.client.client_id,
|
||||
clientName: response.client.name,
|
||||
userId: response.user.user_id,
|
||||
userName: response.user.username,
|
||||
agentModel: response.client.agent_model,
|
||||
agentVersion: response.client.agent_version,
|
||||
client: response.client,
|
||||
user: response.user
|
||||
})),
|
||||
catchError(() => of(null)),
|
||||
shareReplay(1)
|
||||
|
||||
Reference in New Issue
Block a user